You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs for encoding/gob says "Maps are sent as an unsigned count followed by that many key, element pairs. Empty but non-nil maps are sent, so if the sender has allocated a map, the receiver will allocate a map even if no elements are transmitted."
It is not mentioned explicitly, but what if the encoder encodes a nil map, will the decoder create a new map?
The test shows that it will, so the docs should probably be updated to drop the "Empty but non-nil maps
are sent...". In fact, nil maps and empty but non-nil maps are not differentiable.
(nitpicking alert)
The docs for
encoding/gob
says "Maps are sent as an unsigned count followed by that many key, element pairs. Empty but non-nil maps are sent, so if the sender has allocated a map, the receiver will allocate a map even if no elements are transmitted."It is not mentioned explicitly, but what if the encoder encodes a nil map, will the decoder create a new map?
http://play.golang.org/p/U3QI5MW5fV
The test shows that it will, so the docs should probably be updated to drop the "Empty but non-nil maps
are sent...". In fact, nil maps and empty but non-nil maps are not differentiable.
/cc @robpike
The text was updated successfully, but these errors were encountered: