proposal: cmd/vet: vet should warn when time.Time type (or types embed it) is used as map keys. #22978
Labels
Milestone
Comments
I don't think this meets the bar for a vet check. It's perfectly valid to use a time.Time as a map key, if you know what you're doing. I think it would be too noisy for valid code. But somebody could do some analysis on GitHub to see what percentage of time.Time-keyed maps are valid. |
I wrote a linter that detects this type of issue if you're interested: https://github.com/m3db/build-tools/blob/master/linters/badtime/README.md I'm trying to get it integrated with gometalinter right now. |
Now that vet is part of go test, the bar is even higher for new checks. Because it is valid sometimes to have a time.Time as a map key, rejecting it in vet is not OK. You might talk to @dominikh about adding this to megacheck or one of the other linters. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version go1.9.2 linux/amd64
Does this issue reproduce with the latest release?
yes
What did you do?
What did you expect to see?
Like time.Time, there may be some other types, which are not capable to be used as map key types.
What did you see instead?
nothing reported
The text was updated successfully, but these errors were encountered: