proposal: cmd/vet: warn when zero values make explicit initialisation unnecessary #21362
Labels
Milestone
Comments
See cmd/vet/README for guidelines for vet checks. I think this one fails the "correctness" criterion: unnecessary initialization is not a bug. |
@ianlancetaylor
I agree that unnecessary initialisation is not a bug I've filed this as a suggestion for |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
What did you expect to see?
Proposal:
go vet
should warn when initialising a value is unnecessary, i.e. when the zero value for the type is effectively equal to the explicitly initialised valueAs someone new to the language, I have not memorised which types have a zero value and what those zero values are
I will look these up now that I know about them, but
go vet
could help me and others in this caseWhat did you see instead?
go vet
does not indicate any issues about unnecessary initialisationThe text was updated successfully, but these errors were encountered: