# runtime: goroutine 泄漏：net/http.(*persistConn).readLoop 卡住

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

## 根因

HTTP 响应体未关闭，导致持久连接 goroutine 一直阻塞在读取上。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   resp, err := client.Do(req)
if err != nil { return err }
defer resp.Body.Close()
io.Copy(io.Discard, resp.Body)
   ```
2. **** (88% 成功率)
   ```
   ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
req = req.WithContext(ctx)
   ```

## 无效尝试

- **** — Timeout does not close the body; the readLoop goroutine still leaks. (75% 失败率)
- **** — Reusing the client does not fix unclosed bodies. (80% 失败率)
