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: regression from Go 1.1 #6758

Closed
bradfitz opened this issue Nov 13, 2013 · 2 comments
Closed

encoding/gob: regression from Go 1.1 #6758

bradfitz opened this issue Nov 13, 2013 · 2 comments
Assignees
Milestone

Comments

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Nov 13, 2013

(copying here from elsewhere)

The following program changes behavior from Go 1.1 to Go 1.2:

http://play.golang.org/p/9JMYxpJdM_

Before:

$ go version
go version go1.1 linux/amd64
$ go run gob.go
127.0.0.1: 64900
127.0.0.1: 64900

After:

$ go version
go version devel +2a5e92c6efc9 Wed Nov 13 15:32:40 2013 +1100 linux/amd64
$ go run gob.go
127.0.0.1: 64900
127.0.0.1: 0
@rsc
Copy link
Contributor

@rsc rsc commented Nov 13, 2013

Comment 1:

Go 1.2 defines some standard methods for types to encode themselves; see
http://golang.org/s/go12encoding.
encoding/gob will use those methods in preference to its own custom encoding. 
net.IP defines such a method.
In the example, type N2 embeds a net.IP, which means it gets the custom encoding method
from net.IP, which means gob uses that to encode an N2, which means it ignores the other
field. The String method used by fmt.Printf behaves the same way. If you don't want all
the methods from net.IP to attach to N2 (and it seems you do not), you must not embed it
in N2.
http://play.golang.org/p/KT7MJWRypJ
This is fundamental to the way embedding works. The same

Status changed to Unfortunate.

@rsc
Copy link
Contributor

@rsc rsc commented Nov 13, 2013

Comment 2:

s/The same//
For what it's worth, this report led me to notice issue #6760, which seems more serious,
so thank you for that. And the fix might end up removing this regression (or not).
@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.