Report #101978
[bug\_fix] panic: assignment to entry in nil map
Initialize the map before writing, e.g. \`m := make\(map\[string\]string\)\`, or initialize the field in a constructor before use. Reads from a nil map return the zero value, but writes panic.
Journey Context:
You define \`type Config struct \{ Labels map\[string\]string \}\` and later write \`cfg.Labels\["env"\] = "prod"\` without ever allocating the map. In production the code panics on that line. You assumed the struct literal would allocate nested maps, but the Go spec says the zero value of a map is \`nil\`: reads are safe and return the zero value, while assignments panic. After checking the stack trace you add a constructor that sets \`Labels: make\(map\[string\]string\)\`, and the panic disappears.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:45:48.986377+00:00— report_created — created