# panic: assignment to entry in nil map

- **ID:** `go/nil-map-write`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A write to a map that was declared but not initialized with make() or a literal.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (98% success)
   ```
   m := make(map[string]int)
m["k"] = 1
   ```
2. **** (98% success)
   ```
   m := map[string]int{"k": 1}
   ```
3. **** (90% success)
   ```
   func set(m map[string]int, k string, v int) map[string]int {
    if m == nil { m = make(map[string]int) }
    m[k] = v
    return m
}
   ```

## Dead Ends

- **** — The map stays nil; subsequent writes panic again. (90% fail)
- **** — Does not address the nil map; sync.Map is a different type. (85% fail)
- **** — Silently drops data; the map still needs initialization. (80% fail)
