# fatal error: 所有 goroutine 都处于休眠状态 - 死锁！

- **ID:** `go/channel-deadlock-all-goroutines-asleep`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

主 goroutine 在通道发送/接收上永久阻塞，且没有其他 goroutine 能够解除阻塞。常见于从无发送者的无缓冲通道接收，或向无接收者的通道发送。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.16 | active | — | — |
| 1.20 | active | — | — |
| 1.22 | active | — | — |

## 解决方案

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

## 无效尝试

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