-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: cmd/vet: flag invalid json struct tags #41769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cmd/vet does already flag certain kinds of invalid struct tags. This would extend that to look specifically for invalid json struct tags. And, logically, xml, etc. |
One catch here will be tooling outside the Go toolchain that uses these tags. For example, easyjson adds an |
I'm not sure how much there is to do here? Vet already flags duplicate tags: |
That's the question imho. Might be the usefulness is outweighed by this drawback. |
cc @mvdan |
I agree with @dominikh, vet has a high standard for no false positives, so I don't think it can be added. The buggy example you shared originally would be very quickly spotted with a test or by running the code, I presume. I'm also not sure I get the title of the issue. |
Sorry for the confusion, the title was still on the notion of omitempty affecting decoding. Closing this one on the basis of not generating false positives as vet standard. Thanks for the discussion! |
I've recently written codes for json marshaling, containing:
as tag. The error only became obvious when I've added another field with the same tag. It has to be:
I was wondering if vet could/should detect those (and potentially more invalid tags)?
The text was updated successfully, but these errors were encountered: