ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.86k stars 295 forks source link

Document that omitempty is ignored with toarray #198

Closed akalin-keybase closed 7 years ago

akalin-keybase commented 7 years ago

e.g. with

       type t1 struct {
               _struct bool `codec:",toarray"`
               B1 bool
               B2 bool `codec:",omitempty"`
       }

B2 will always be encoded.

This isn't explicitly mentioned anywhere, and an example in http://ugorji.net/blog/go-codec-primer (type My2) incorrectly suggests it's possible. Or maybe it's planned to be? It would seem to be complicated/ambiguous in the general case, though.

ugorji commented 7 years ago

Thanks.

Toarray means everything must be encoded, as we map the position to the array to the position of the field in the struct.

Will update comments and doc and then close.

ugorji commented 7 years ago

Also updated doc at http://ugorji.net/blog/go-codec-primer