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
time.UTC() changes the value of time.Now().UTC().Round(time.Millisecond) #43630
Comments
Have you tried running |
The test is synchronous. I'm assuming a different explanation for why this only happens sometimes, is because it's dependent on the actual time values stored in |
As documented at https://golang.org/pkg/time/#Time, using |
Actually we just had a unittest failure for the above logic, that uses I haven't dug through all the code, but I'm suspecting that And I believe |
If you think there is a bug here I think you need to show us a complete, standalone, test case. Thanks. |
Thanks for your help, @ianlancetaylor and @AlexRouSg. It turns out it was a problem in our code all along, and I was just confused by the Go internal time representation. Closing this out. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes,
go1.15.6
is the latest releaseWhat operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have code and unit tests for my real system that boils down to this:
https://play.golang.org/p/4afKq3-_kHI
My "real world unittest" fails like this (expected=now, actual=t2):
What did you expect to see?
I expected that
now == t2
would always return true. I realize this may be arguable. Perhaps that's where I went wrong?Specifically, I expected that calling
now.UTC()
in my example would be a no-op, sincenow
is already inUTC
.What did you see instead?
I see
now != t2
occasionally, which I didn't expect.The text was updated successfully, but these errors were encountered: