Skip to content
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

go/lint: enforce camelCase in json struct tags #275

Open
sethlivingston opened this issue Aug 17, 2023 · 4 comments
Open

go/lint: enforce camelCase in json struct tags #275

sethlivingston opened this issue Aug 17, 2023 · 4 comments
Labels

Comments

@sethlivingston
Copy link

camelCase is the capitalization preferred in JavaScript. I know JSON is read by many different languages, but having a mix of different capitalization in json struct tags isn't a good idea. We should ask authors to use camelCase.

@adamdecaf adamdecaf changed the title go/lint: add a warning for camelCase in json struct tags go/lint: enfroce camelCase in json struct tags Aug 17, 2023
@adamdecaf adamdecaf changed the title go/lint: enfroce camelCase in json struct tags go/lint: enforce camelCase in json struct tags Aug 17, 2023
@adamdecaf
Copy link
Member

adamdecaf commented Aug 17, 2023

Go doesn't have warnings, but we can probably require camelCase. Go doesn't care when reading JSON, but some languages like javascript do. We support languages besides the web, but a common standard of camelCase would be good.

@adamdecaf
Copy link
Member

Looks like we can support this request with https://golangci-lint.run/usage/linters/#tagliatelle

@sethlivingston
Copy link
Author

Want me to submit a PR?

@adamdecaf
Copy link
Member

adamdecaf commented Aug 17, 2023

Yes, I think we can just enable the linter. By default it won't require us to have field names and struct tags match, which is probably fine. I know there are some cases where we deviate struct from json for readability. The defaults for json and yaml camelcase work for us. If we wanted to be stricter we could force use-field-name: true and offer an env var to disable.

I don't think we need to use a config file for this linter, so we aren't dependent on #274.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants