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

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

## Root Cause

A goroutine attempts to receive from a nil channel, which blocks indefinitely, causing a deadlock if no other goroutine can unblock it.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.19 | active | — | — |
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Ensure channel is initialized before use** (100% success)
   ```
   ch := make(chan int)
// use ch
   ```
2. **Use a default case in select to avoid blocking** (90% success)
   ```
   select {
case val := <-ch:
    // process
case <-time.After(1 * time.Second):
    // timeout
}
   ```

## Dead Ends

- **Initialize channel in init()** — If the channel is used before init() runs, it remains nil. (60% fail)
- **Ignore the nil channel and add a timeout** — Timeout doesn't fix the root cause; the channel is still nil and will block again. (80% fail)
