Attempting to insert a key-value pair into an uninitialized nil map variable.
In Go, map zero values are `nil`. Reading from a nil map is safe (returns zero value), but writing to a nil map triggers a runtime panic.
Declaring a map with `var m map[string]int` without initializing it using `make()` or map literal before inserting keys.
1package main2 3func main() {4 var counts map[string]int // counts is nil!5 counts["apples"] = 5 // Panic: assignment to entry in nil map6}1package main2 3import "fmt"4 5func main() {6 // Fix 1: Initialize with make()7 counts := make(map[string]int)8 counts["apples"] = 59 10 // Fix 2: Initialize with composite literal11 scores := map[string]int{}12 scores["alice"] = 10013 14 fmt.Println(counts, scores)15}Simulate standard system builds to trigger compiler trace records and track memory crashes locally.
Declaring `var counts map[string]int` leaves `counts` as `nil`. Inserting `counts["apples"] = 5` fails because hash table bucket buffers are not allocated.