You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While doing more investigation and revising my tests for #19486 I discovered that the roundtrip through Marshal/Unmarshal returns different data structures.
Note that #15716, while similar, only tests roundtrips for marshaling with the zero Time and doesn't spot this mismatch.
I'm not sure if this is actually a bug or intended behavior, but it's surprising enough to report.
Actually, I think this is intended behavior, as pointed out in the docs for package time:
// Because the monotonic clock reading has no meaning outside
// the current process, the serialized forms generated by t.GobEncode,
// t.MarshalBinary, t.MarshalJSON, and t.MarshalText omit the monotonic
// clock reading, and t.Format provides no format for it. Similarly, the
// constructors time.Date, time.Parse, time.ParseInLocation, and time.Unix,
// as well as the unmarshalers t.GobDecode, t.UnmarshalBinary.
// t.UnmarshalJSON, and t.UnmarshalText always create times with
// no monotonic clock reading.
//
// Note that the Go == operator includes the monotonic clock reading in
// its comparison. If time values returned from time.Now and time values
// constructed by other means (for example, by time.Parse or time.Unix)
// are meant to compare equal when used as map keys, the times returned
// by time.Now must have the monotonic clock reading stripped, by setting
// t = t.AddDate(0, 0, 0). In general, prefer t.Equal(u) to t == u, since
// t.Equal uses the most accurate comparison available and correctly
// handles the case when only one of its arguments has a monotonic clock
// reading.
While doing more investigation and revising my tests for #19486 I discovered that the roundtrip through Marshal/Unmarshal returns different data structures.
Note that #15716, while similar, only tests roundtrips for marshaling with the zero Time and doesn't spot this mismatch.
I'm not sure if this is actually a bug or intended behavior, but it's surprising enough to report.
What version of Go are you using (
go version
)?failing: 0e3355903d2ebcf5ee9e76096f51ac9a116a9dbb and later (this switched to using a monotonic clock)
passing: 8179b9b462eb2946de8488a26dca91a89b3d22e6 and before
What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
I expected the structures to be identical.
What did you see instead?
At 0e33559 I get this failure:
The text was updated successfully, but these errors were encountered: