Skip to content

case-insensitive-string-comparison

Detect allocating case conversions used only for comparison.

Updated View as Markdown

Default severity: warning

Converting both strings with strings.ToLower or strings.ToUpper allocates intermediate strings and processes each input fully. strings.EqualFold compares incrementally without those allocations and can stop at the first mismatch.

Bad

if strings.ToLower(left) == strings.ToLower(right) { use() }

Good

if strings.EqualFold(left, right) { use() }
Navigation

Type to search…

↑↓ navigate↵ selectEsc close