# 致命错误：所有 goroutine 都处于休眠状态 - 死锁！

- **ID:** `go/deadlock-on-unbuffered-channel-send`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在同一 goroutine 中向无缓冲通道发送数据而没有对应的接收者会导致死锁。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.0 | active | — | — |
| 1.21 | active | — | — |

## 解决方案

1. **Ensure a separate goroutine receives from the channel before sending** (95% 成功率)
   ```
   go func() { <-ch }(); ch <- data
   ```
2. **Use a buffered channel with sufficient capacity** (90% 成功率)
   ```
   ch := make(chan int, 1); ch <- 42
   ```

## 无效尝试

- **Adding a small sleep before sending** — Sleep does not create a receiver; the send still blocks indefinitely. (90% 失败率)
- **Using a buffered channel with capacity 1 but still no receiver** — Buffered channel only helps if capacity is not exceeded; if no receiver, the send blocks after buffer fills. (80% 失败率)
