go-tools: staticcheck: Report incorrect equality checks of time.Time values.
Package time documents that:
Do not use == with Time values.
(Source: https://godoc.org/time#Time.Equal.)
This probably extends to != for inequality checks too.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 15 (14 by maintainers)
Reopening under the
aggressivelabel, for a future set of checks specific to code review.What makes you say that?
Read the entire paragraph I quoted in https://github.com/dominikh/go-tools/issues/47#issuecomment-283490396, it pretty much says explicitly that you can use
time.Timevalues as map keys, provided you perform the neccessary actions to make==operator work as expected (and there are extra considerations in Go 1.9 compared to 1.8).Anyway, I’m tracking dealing with this issue upstream at https://github.com/shurcooL/backlog/issues/31.
I’ve used
==in the past with times I have calledUTC()on, so I’m inclined to believe this would be too strict.