-
Notifications
You must be signed in to change notification settings - Fork 18k
time: Time Zero MarshalJSON / UnmarshalJSON produces a different object #10089
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
Comments
Parsing a time will get a non-zero location. This is working as intended. You shouldn't use == to compare time.Time's. |
@minux then this looks like a DeepEqual bug |
No. DeepEqual is documented to use ==.
|
@minux exactly, but as you said, it shouldn't if that's not the way to compare Time |
@simon3z wrong conclusion.
If you need a |
@cespare probably a better design would be something like:
do you think it could be something I could write/include in the reflect package? |
@simon3z Better deep comparison is interesting, but let's take this to the golang-nuts mailing list. |
@simon3z If you really care about comparing times directly (part of larger struct), you can get away by keeping times in the same timezone (like http://play.golang.org/p/GhvxWMgk-x), but it just workarounds the fact they should be compared with http://golang.org/pkg/time/#Time.Equal. |
It seems that marshaling and unmarshaling a zero time produces an object that is different from the original:
The text was updated successfully, but these errors were encountered: