Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

encoding/gob: Go 1.2 cannot decode Go 1.1 gobs containing net.IP #6760

Closed
Milestone
@rsc

Description

@rsc
In Go 1.2, encoding/gob respects the new encoding.TextMarshaler andencoding.TextUnmarshaler methods, and net.IP adds those methods.Unfortunately, this means that the gob encoding of a net.IP changes from Go 1.1 to Go1.2. That by itself might be okay: I don't believe people expect that Go 1.1 will beable to read Go 1.2 gobs.However, gob is also a bit picky about the decoding: if the type has a TextUnmarshaler,gob expects to get the TextMarshaler version of the encoding and does not accept anencoding of the underlying data. A Go 1.1 gob encoding of a net.IP will send the gob encoding of a standard []byte. Go1.2 gob will refuse to decode that form.The only other type we have added a MarshalText or MarshalBinary method to is time.Time.But time.Time already had a GobEncode and GobDecode methods, so its behavior with gobdoes not change. It appears that net.IP is the only affected type in the standardlibrary.Possibilities:1. Do nothing; allow Go 1.1 and Go 1.2 to be mutually unintelligible in gob when thereis a net.IP involved.2. Change gob to accept the concrete data representation during decode, so that Go 1.1can talk to Go 1.2 but not vice versa.3. Change gob to ignore MarshalText/UnmarshalText, allowing onlyMarshalBinary/UnmarshalBinary.4. Remove net.IP's MarshalText/UnmarshalText methods, breaking encoding/json's supportfor net.IP (new in Go 1.2).5. Replace net.IP's MarshalText/UnmarshalText methods with MarshalJSON/UnmarshalJSON, sothat we keep encoding/json working well for Go 1.2. (Of course, the new generic methodswere designed explicitly to avoid making package net mention JSON, so it is a bit of ashame not to use them.)I am leaning toward 5, which seems like the most limited change.Rob, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp