-
Notifications
You must be signed in to change notification settings - Fork 18k
encoding/gob: cannot decode into top-level interface type #2367
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
Labels
Milestone
Comments
Owner changed to @robpike. Status changed to Accepted. |
In gob streams, values to be encoded as interfaces must be sent as interfaces. In this case, a struct is being sent and an interface is requested for the decode. This program is therefore incorrect and in general cannot easily be made to work since the sender has not explained the required interface specification in the stream. Open to suggestions: 1) document this property better 2) provide better error message (although all the information is in the existing message, it could always be clearer) 3) possibly make it work in cases where it can, specifically an empty interface receiver. I do not favor this. |
I think it would be worth making this work - it's the classic use case of a stream of differently typed messages. Requiring a container type just to get around this restriction seems a bit silly to me. However, looking at the protocol I do see the problem. Better documentation is probably the answer. |
This issue was closed by revision ba576b2. Status changed to Fixed. |
Issue #2938 has been merged into this issue. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: