# 错误：收到意外的零值（channel 已关闭，忽略了 ok=false）

- **ID:** `go/receive-from-closed-channel-zero-value`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

从已关闭的 channel 读取会永远立即返回零值。忽略 'ok' 布尔值的代码把零值当作真实数据，造成静默的数据损坏。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use the comma-ok idiom: 'v, ok := <-ch; if !ok { return }' and break the loop on close
   ```
2. **** (93% 成功率)
   ```
   Use 'for v := range ch { ... }' which terminates automatically when the channel closes
   ```

## 无效尝试

- **** — Closed channel always returns immediately; sleep just delays the wrong value (80% 失败率)
- **** — len is a snapshot and racy; does not distinguish closed from empty (85% 失败率)
