Skip to content

case-insensitive-string-comparison

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.

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