---
title: "never-nil-comparison"
description: "Detect nil checks on values proven to be non-nil."
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.

# never-nil-comparison

**Default severity:** `error`

Fresh allocations, `make` results, functions, closures, and values flowing
exclusively from those sources cannot be nil. Comparing them with nil has a
fixed result and often means the wrong value was checked.

## Bad

```go
values := make([]int, 0); if values == nil { unreachable() }
```

## Good

```go
var values []int; if values == nil { initialize() }
```

Source: https://strider.gempir.com/analyzers/never-nil-comparison/index.mdx
