# fatal error: all goroutines are asleep - deadlock!

- **ID:** `go/channel-deadlock-all-goroutines-asleep`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The main goroutine blocked forever on a channel send/receive with no other goroutine able to unblock it. Common when receiving from an unbuffered channel with no sender, or sending with no receiver.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.16 | active | — | — |
| 1.20 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   ch := make(chan int, 1)
ch <- 1 // non-blocking
v := <-ch
   ```
2. **** (85% success)
   ```
   select {
case v := <-ch:
    use(v)
case <-time.After(2 * time.Second):
    return errors.New("timeout")
}
   ```

## Dead Ends

- **** — Buffering only delays the deadlock. Once the buffer fills, the same blocking occurs; if the logic is fundamentally single-goroutine, it deadlocks regardless. (70% fail)
- **** — Sleeps don't create concurrency; if there is no sender goroutine at all, no amount of waiting helps. (85% fail)
