{
  "id": "go/goroutine-receive-from-closed-channel",
  "signature": "panic: receive from closed channel",
  "signature_zh": "恐慌：从已关闭的通道接收数据",
  "regex": "panic:\\ receive\\ from\\ closed\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to receive from a channel that was closed while a goroutine is waiting, but the panic occurs only if the channel is nil.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试从已关闭的通道接收数据，但仅当通道为nil时才会发生恐慌。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Checking channel with cap() before receive",
      "why_fails": "cap() does not indicate closed state.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover() to ignore panic",
      "why_fails": "Recover does not prevent data corruption.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use comma-ok idiom to detect closed channel",
      "success_rate": 0.95,
      "how": "v, ok := <-ch; if !ok { /* channel closed */ }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure channel is not nil before receive",
      "success_rate": 0.8,
      "how": "if ch != nil { v := <-ch }",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}