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: new gob support for interface{} breaks for built-in types #1230

Closed
msolo opened this issue Oct 26, 2010 · 3 comments
Closed

encoding/gob: new gob support for interface{} breaks for built-in types #1230

msolo opened this issue Oct 26, 2010 · 3 comments

Comments

@msolo
Copy link
Contributor

msolo commented Oct 26, 2010

Thanks for the support to interface{} - I actually have a great usecase for it in my app.

I discovered the bug writing some throw-away code.

If you have a struct like so:

type Test struct {
 Anything interface{}
}

t := Test{"teststring"}

gob.Encode gives you:

2010/10/21 17:29:11 rpc: writing response: gob: type not registered for interface: string

calling gob.Register("") from my init() solves the problem, but it seems like
encodeInterface() needs to check built-in types as well as concreteTypeToName.
@msolo
Copy link
Contributor Author

msolo commented Oct 26, 2010

Comment 1:

Follow-up - calling gob.Register("") actually screwed up the encoding of other types
when I plugged in the rpc system.
The internal state of the decoder looked like this:
error range 3 >= 2 []gob.decInstr{gob.decInstr{op:(gob.decOp)(0x8090e0f), field:0,
indir:0, offset:0x0, ovfl:"value for \"name\" out of range"},
gob.decInstr{op:(gob.decOp)(0x80906ca), field:1, indir:0, offset:0x8, ovfl:"value for
\"_id\" out of range"}}

@robpike
Copy link
Contributor

robpike commented Oct 26, 2010

Comment 2:

Thanks for the clear bug report. This is indeed a simple oversight.

Status changed to Started.

@robpike
Copy link
Contributor

robpike commented Oct 27, 2010

Comment 3:

This issue was closed by revision f437d4d.

Status changed to Fixed.

@mikioh mikioh changed the title new gob support for interface{} breaks for built-in types encoding/gob: new gob support for interface{} breaks for built-in types Feb 26, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 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
Development

No branches or pull requests

3 participants