---
title: "case-insensitive-string-comparison"
description: "Detect allocating case conversions used only for comparison."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.

## Bad

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

## Good

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

Source: https://strider.gempir.com/analyzers/case-insensitive-string-comparison/index.mdx
