{
  "id": "go/channel-receive-from-nil",
  "signature": "panic: runtime error: receive from nil channel",
  "signature_zh": "恐慌：运行时错误：从 nil 通道接收",
  "regex": "panic:\\ runtime\\ error:\\ receive\\ from\\ nil\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to receive from a channel that is nil, causing permanent block, but if in select with default, it may not panic; however, direct receive panics.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试从 nil 通道接收，导致永久阻塞，但如果 select 中有 default 可能不会恐慌；然而直接接收会恐慌。",
  "versions": [
    {
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Checking ch == nil before receive and returning",
      "why_fails": "Check prevents panic but may cause silent data loss.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover to catch panic",
      "why_fails": "Panic is recoverable but indicates logic error; data not received.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize channel before use",
      "success_rate": 1.0,
      "how": "ch := make(chan int); go func() { ch <- 1 }(); val := <-ch",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use select with default to handle nil channel gracefully",
      "success_rate": 0.9,
      "how": "select { case val := <-ch: use(val); default: // skip }",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}