-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Enable gocritic equalFold and autofix issues #34678
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
I won't block it but IMO EqualFold is not a right approach if we only want to handle ASCII chars. Sometimes it is just abused.
|
I see it as a benefit that it handles unicode as well. More often than not you want unicode comparison, especially when dealing with user-submitted data. |
Why it makes sense to use Unicode for HTTP headers or something else? Doesn't it break the standard if the headers are "folded" by unicode chars? |
In short:
|
Looks like there is a ASCII-only variant https://pkg.go.dev/net/http/internal/ascii#EqualFold Not sure if usable because its in |
Yup, we need to implement one by ourself, something like "strcasecmp/stricmp" in C, or we can just call it |
|
Related golang issue: golang/go#68736 |
Enable https://go-critic.com/overview.html#equalfold, which is marked experimental, so was not enabled by default and ran
make lint-go-fix
. Reasons whystrings.EqualFold
is preferred here.