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
net/url: Userinfo should support encoding/gob #10964
Comments
Or perhaps /cc @robpike |
Implementing |
If we're going to do something for url.URL, why not give URL MarshalText/UnmarshalText methods instead? Why work on this tiny piece of the URL instead of the whole thing? That said, we have to proceed very carefully here because of backwards compatibility concerns. It may not happen for 1.6. |
This works too. MarshalText could call URL.String, and UnmarshalText could call url.Parse. It is very straightforward. How would this break backward compatibility? If someone is relying on the fact that url.URL cannot be marshaled or unmarshaled? |
@chowey It's a change in behavior. It can surprise people. And if it can, it will. We've struggled with this when adding custom encodings for other types as well. |
CL https://golang.org/cl/31467 mentions this issue. |
Currently the
encoding/gob
package does not support embedded structs with no exported fields. See #5819.This is problematic for the
net/url
package. I cannot serialize aurl.URL
into a gob becauseurl.Userinfo
has no exported fields. I can't be the only one who has needed to serialize a struct with a URL in it.This is solvable without modification to the
encoding/gob
if we fixurl.Userinfo
. This is possible by implementingencoding.BinaryMarshaler
andencoding.BinaryUnmarshaler
:The text was updated successfully, but these errors were encountered: