-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add new linter canonicalheader #4241
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
Conversation
fe31441
to
ebc5620
Compare
Canonicalheader checks http header via http.CanonicalHeaderKey().
ebc5620
to
5e8074f
Compare
In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.
Pull Request Description
Linter
The Linter Tests Inside Golangci-lint
|
|
Yes, you are right. Thank you for research, these SA1008 can't report about wrote with methods to Headers, I will create PR in I close this PR. |
Here is the issue that was raised by @lasiar on staticcheck dominikh/go-tools#1519 (comment) They declined enforcing it at staticcheck level. |
canonicalheader analyzes code and reports or fixes non-canonical header key in net/http.Header, doc.
The linter suggest canonical header:
instead of non-canonical header:
This change also speeds up the code a little, benchmark from repo:
Now, the linter works only with value net/http.Header (not pointer) and with string literal.