# fatal error: all goroutines are asleep - deadlock! (receive on nil channel)

- **ID:** `go/receive-on-nil-channel-blocks`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A receive from a nil channel blocks forever. If the channel variable was never assigned and is used in a select or receive, the goroutine hangs permanently.

## Version Compatibility

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

## Workarounds

1. **** (92% success)
   ```
   ch := make(chan int)
go func() { ch <- 1 }()
v := <-ch
fmt.Println(v)
   ```
2. **** (85% success)
   ```
   select {
case v := <-ch:
    fmt.Println(v)
case <-ctx.Done():
    return ctx.Err()
}
   ```

## Dead Ends

- **** — It prevents the hang but the underlying nil channel is still never populated, so the program silently times out instead of working. (50% fail)
- **** — The default case fires immediately forever, spinning in a busy loop consuming CPU. (70% fail)
