{
  "id": "go/receive-from-closed-channel-loop",
  "signature": "error: infinite loop reading zero values from closed channel",
  "signature_zh": "error: 从已关闭 channel 无限读取零值",
  "regex": "error:\\ infinite\\ loop\\ reading\\ zero\\ values\\ from\\ closed\\ channel",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A for v := range ch loop is expected to terminate, but a for { v := <-ch } loop keeps returning zero values forever after close because receives from a closed channel never block.",
  "root_cause_type": "generic",
  "root_cause_zh": "期望 for v := range ch 终止,但写成 for { v := <-ch } 的循环在 channel 关闭后会永远返回零值,因为从已关闭 channel 接收永不阻塞。",
  "versions": [
    {
      "version": "1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Does not stop the loop; still processes infinite zero values and corrupts data.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Zero is a legitimate value; breaks on real data and still races with close.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.97,
      "how": "for {\n    v, ok := <-ch\n    if !ok {\n        return\n    }\n    process(v)\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.98,
      "how": "for v := range ch {\n    process(v)\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}