Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/gob: decoder always creates map even if encoder encodes a nil map (docs issue) #10908

Closed
minux opened this issue May 19, 2015 · 1 comment
Milestone

Comments

@minux
Copy link
Member

minux commented May 19, 2015

(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

@minux minux added this to the Go1.5 milestone May 19, 2015
@minux minux self-assigned this May 19, 2015
@gopherbot
Copy link

CL https://golang.org/cl/10250 mentions this issue.

@minux minux closed this as completed in 91191e7 May 20, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned minux Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants