go-tools
go-tools copied to clipboard
Enforce that `interface{}` is spelled `any`
I propose to flag when interface{}
is written instead of any
. Maybe for Go 1.20+ or so, since it was added in Go 1.18?
It's easy to fix up a codebase to use any
with, for instance,
gofmt -w -r 'interface{} -> any' .
I suspect this might be controversial but I wanted to throw it out there since I'm implementing this now in our company-internal linter.
(I feel like there must have been previous discussion about this, either as part of staticcheck or as part of vet or even as an automatic gofmt feature, but my searches haven't turned up anything. It's difficult to search for these terms.)
This is definitely (too) controversial for a default check, it's pretty much nitpicking existing code for no practical reason. We could maybe consider it as an optional style check, but I'd like to delay even that by a couple more versions.
As for prior discussion: https://github.com/golang/go/issues/33232#issuecomment-923069224