-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: diagnose xml/json tag with space after comma #19520
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
I'd rather there just be one way to do this. If we were going to do this we'd want to do it for everything that parses struct tags (xml, etc), which would introduce a difference between older versions and go1.9+ in how output data gets generated. If anything, if it's feasible I'd rather |
We already vet for struct with duplicate json tags (on different fields). We could easily also check for unexpected spaces. That's probably better than introducing new spellings, especially if we start running vet automatically during tests. |
OK, let's just have vet do this. |
Contributions welcome. Note that vet already looks at json/xml tags. |
This seems like a low-hanging fruit, I can give it a stab. To be clear,
Or is this more narrowly aimed at the json/xml annotations? |
CL https://golang.org/cl/43295 mentions this issue. |
Did we also changed Another issue is that
Here the notion of
Any thoughts here? |
What version of Go are you using (
go version
)?go version go1.8 windows/amd64
What did you do?
I have tried to use a struct tag value
json:"Name, string"
to cause primitive fields to be quoted by double quotes inside JSON strings, but it doesn't affect because an space is written between a comma[,] and string, I don't know the reason until I read the code of json.What did you expect to see?
I propose that any spaces can be ignored between commas[,], just as the Go grammar did,to help us avoid mistakes such as one unobvious space after a comma.
Here is the example for the difference with/without a space after the comma
output:
expected:
Propose
Here is one way to ignore spaces between comma,
output of last example:
The text was updated successfully, but these errors were encountered: