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

strings: EqualFold doc could be clearer #33447

kevinburke opened this issue Aug 3, 2019 · 1 comment


Copy link

commented Aug 3, 2019

The doc for EqualFold says:

EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding.

I have been using Go for over five years now and had no idea what "Unicode case-folding" was until about three minutes ago. Previously I had implemented this by calling strings.ToLower on each side, which is slow and unnecessary. More commonly I believe the EqualFold functionality is known as "case insensitive matching." Users who are searching the strings documentation for the phrase "case insensitive" will find nothing, when they should be finding this function.

Scanning Github this seems like a common mistake:

Several Go vetters/linters have checks for this construction that suggest using EqualFold instead:

StackOverflow answers suggesting the use of EqualFold have 35,000 views and 10,000 views, respectively.


This comment has been minimized.

Copy link

commented Aug 3, 2019

I agree that this doc can be made clearer. How about adding a clause to say that it basically does a more general form of case-insensitive matching? Something like:

EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under Unicode case-folding, a generalization of case-insensitivity.

@dmitshur dmitshur added this to the Go1.14 milestone Aug 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.