cmd/vet: structtag field repeats json warning with valid override #40102
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
When embedding two structs with duplicate JSON tags, e.g.:
A
structtag
warning is raised by go vet. I think a reasonable workaround to the warning is to override the duplicate-tag on the top level, per extra rules here: https://golang.org/pkg/encoding/json/#Marshal, e.g.But
go vet
still raises the warning.Note I did add the flag
-structtag=false
as a workaround but there are cases where I would like to be alerted, but only when no override has been setWhat did you expect to see?
go vet
treats top-levelstructtag
overrides as a valid solution and no longer raises a warning.What did you see instead?
go vet
ignores the top-level override, resulting instructtag: struct field X repeats json tag "[X]" also at XXXX.go:XXX (govet)
The text was updated successfully, but these errors were encountered: