slices in go are weird. they are basically pointer to a sliceHeader, so there is no need for another header. For example:
var s []int
s == nil
len(s) == 0
actually allocate the header
s := []int{}
s != nil
len(s) == 0
The former will jsonify to null the latter will jsonify to [] but they will both be excluded by omitempty . That may start to matter when you provide results in json. https://play.golang.org/p/EGl1hcJg9E9
slices in go are weird. they are basically pointer to a sliceHeader, so there is no need for another header. For example:
actually allocate the header
The former will jsonify to
null
the latter will jsonify to[]
but they will both be excluded byomitempty
. That may start to matter when you provide results in json. https://play.golang.org/p/EGl1hcJg9E9also removed some trailing whitespace.