Normally, I will initialize a struct like:
item1 := Item{1, "Foo"}
However, I've recently seen code initializing with parens:
item2 := (Item{2, "Bar"})
reflect
returns the same Item
name.
What does initializing in parentheses do and when is it preferred?
Here's some Go code to try this out:
- Playground: https://play.golang.org/p/_gsaruS_DVi