# fatal error: all goroutines are asleep - deadlock! (unbuffered channel)

- **ID:** `go/unbuffered-channel-blocking`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

An unbuffered channel requires both sender and receiver to be ready simultaneously. If only one side is ready, it blocks indefinitely.

## Version Compatibility

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

## Workarounds

1. **Ensure both sender and receiver are started before the blocking operation** (90% success)
   ```
   ch := make(chan int)

go func() {
    val := <-ch
    fmt.Println(val)
}()

ch <- 42 // now this won't block because receiver is ready
   ```
2. **Use a buffered channel with a reasonable capacity** (80% success)
   ```
   ch := make(chan int, 10) // buffer size 10
   ```

## Dead Ends

- **Making the channel buffered with a small size** — A small buffer may not be sufficient; if the buffer fills up, the same deadlock can occur. (50% fail)
- **Using time.Sleep to give the other side time to prepare** — Sleeping is non-deterministic and doesn't guarantee both sides are ready; it may still deadlock. (75% fail)
