# runtime: 检测到 goroutine 泄漏：N 个 goroutine 阻塞在通道发送上

- **ID:** `go/goroutine-leak-http-server`
- **领域:** go
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

处理程序启动的 goroutine 向无人消费的通道写入，或在永不关闭的通道上等待，客户端断开后 goroutine 持续累积。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   go func() {
    select {
    case ch <- result:
    case <-ctx.Done():
        return
    }
}()
   ```
2. **** (85% 成功率)
   ```
   results := make(chan Result, len(tasks))
   ```

## 无效尝试

- **** — Leaked goroutines still hold stacks and channel references; memory grows regardless of scheduler tuning. (75% 失败率)
- **** — GC does not collect goroutines that are still runnable or blocked on a channel. (90% 失败率)
