Skip to content

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.

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