# goroutine 泄漏：goroutine 阻塞在通道发送

- **ID:** `go/goroutine-leak-blocked-on-channel-send`
- **领域:** go
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

一个 goroutine 向无人接收的通道发送数据，通常是因为接收方提前退出，或通道无缓冲且没有活跃的接收者。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   Use select with context cancellation:
select {
case ch <- val:
case <-ctx.Done():
    return
}
   ```
2. **** (88% 成功率)
   ```
   Ensure the receiver always drains the channel or closes it to unblock senders. Use a done channel to signal shutdown.
   ```

## 无效尝试

- **** — Only delays the leak; if buffer fills, goroutine still blocks. (70% 失败率)
- **** — Leaks accumulate over time, causing memory growth and eventual OOM. (90% 失败率)
