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

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

## Root Cause

An unbuffered channel send blocks until a receiver is ready; if no receiver exists, the goroutine deadlocks.

## Version Compatibility

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

## Workarounds

1. **Use a buffered channel to allow sends without immediate receiver.** (95% success)
   ```
   ch := make(chan int, 1)
ch <- 42 // non-blocking
val := <-ch
fmt.Println(val)
   ```
2. **Ensure a receiver goroutine is started before sending.** (100% success)
   ```
   ch := make(chan int)
go func() {
    val := <-ch
    fmt.Println(val)
}()
ch <- 42 // now receiver is ready
   ```

## Dead Ends

- **Using a buffered channel but with size 0, which is unbuffered.** — make(chan int, 0) creates an unbuffered channel, still blocking. (90% fail)
- **Adding a receiver in the same goroutine after the send.** — The send blocks before the receiver is reached, causing deadlock. (100% fail)
