-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
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:
https://github.com/sachin-varade/network/blob/5d4ab4a3757603b8c0ba9a9df7bc9e0ff92ad102/app/utils/setup/chaincode/processors/read_ledger.go#L172
https://github.com/projectriri/bot-gateway/blob/d4402bd4ac0d4478bd86e585ca83e9d3fc1c140e/converters/cqhttp-ubm-conv/cqhttp-ubm-conv.go#L79
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.
https://stackoverflow.com/q/24836044/329700
https://stackoverflow.com/q/30196780/329700