go version
)?go version go1.9.2 linux/amd64
yes
package main
import "time"
type T struct {
time.Time
}
var a map[T]string
func main() {
}
$ go vet a.go
$ [nothing reported]
$ go vet a.go
$ time.Time is not a good map key type.
Like time.Time, there may be some other types, which are not capable to be used as map key types.
nothing reported
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.
Most helpful comment
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.