Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created November 29, 2022 12:30
Show Gist options
  • Save tebeka/37d5ee7e6dc33f15adf85a0b054b927d to your computer and use it in GitHub Desktop.
Save tebeka/37d5ee7e6dc33f15adf85a0b054b927d to your computer and use it in GitHub Desktop.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment