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

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

## Root Cause

A goroutine tries to send on an unbuffered channel without a corresponding receiver ready, causing it to block forever. If all goroutines are blocked, the program deadlocks.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0 | active | — | — |
| 1.1 | active | — | — |

## Workarounds

1. **Ensure the receiver is ready before sending** (95% success)
   ```
   ch := make(chan int)
go func() {
    val := <-ch
    fmt.Println(val)
}()
ch <- 42
   ```
2. **Use a select with a default case to make send non-blocking** (90% success)
   ```
   select {
case ch <- 42:
default:
    fmt.Println("no receiver, dropping message")
}
   ```

## Dead Ends

- **Using a buffered channel with size 1 to avoid blocking** — A buffered channel can hold one value, but if the receiver never reads, the buffer will fill up and subsequent sends will block, leading to the same deadlock. (85% fail)
- **Adding a time.Sleep before sending to wait for receiver** — Sleep is unreliable; the receiver may not be ready in time, and it introduces unnecessary delays. (90% fail)
