Skip to content

nil-map-assignment

Detect assignments into maps proven to be nil.

Updated View as Markdown

Default severity: error

Reading from a nil map is allowed, but assigning an entry to a nil map panics. Initialize the map with make or a map literal before writing.

Bad

var values map[string]int; values[key] = value

Good

values := make(map[string]int); values[key] = value
Navigation

Type to search…

↑↓ navigate↵ selectEsc close