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
Note that the Go == operator compares not just the time instant but also the Location and the monotonic clock reading. Therefore, Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values, which can be achieved through use of the UTC or Local method, and that the monotonic clock reading has been stripped by setting t = t.Round(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.
The text was updated successfully, but these errors were encountered:
As the quoted passage says, it is possible to compare time.Time values directly and successfully, by stripping monotonic time and ensuring timezones are identical. I know of at least one major project that does this successfully. As such, we cannot categorically ban comparing time.Time values.
https://golang.org/pkg/time/#Time says:
The text was updated successfully, but these errors were encountered: