Archive for July, 2014

Go Struct Initialization with Named Literals

July 25th, 2014

The preferred way of initializing a struct is with named literals.
If the struct has non exported fields, and being called from other package, not using named literals will produce a compiler error like:
./main.go:65: too few values in struct initializer
In this case it’s required, but using them as a general practice can help avoid code breaking […]