Report #97687
[bug\_fix] panic: runtime error: invalid memory address or nil pointer dereference \[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x...\]
Initialize the map with \`make\(map\[string\]int\)\` before writing to it. If the map is shared across goroutines, use \`sync.Map\` or protect with a mutex.
Journey Context:
A developer was adding a new feature that stored counters in a simple map. The map was declared as \`var counter map\[string\]int\` but never initialized with \`make\`. The code compiled fine, but on the first HTTP request that tried to set \`counter\["hits"\]\+\+\`, the program panicked with a nil pointer dereference. The developer spent 30 minutes checking all pointers in the handler, then realized the map was nil. Adding \`counter = make\(map\[string\]int\)\` in the init function fixed the crash. The error is extremely common because Go's zero value for a map is nil and writing to a nil map causes a panic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:51:39.828050+00:00— report_created — created