{
  "id": "go/close-of-nil-channel",
  "signature": "panic: close of nil channel",
  "signature_zh": "panic: 关闭 nil channel",
  "regex": "panic:\\ close\\ of\\ nil\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "close() was called on a channel variable that was never initialized with make() or was set to nil, typically after a failed conditional assignment.",
  "root_cause_type": "generic",
  "root_cause_zh": "对未用 make() 初始化、或经条件赋值后变为 nil 的 channel 变量调用了 close()。",
  "versions": [
    {
      "version": "1.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This masks the real bug: the channel was supposed to be created. Downstream senders/receivers now block forever on a nil channel instead of panicking, turning a crash into a hang.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the defect and leaks the goroutines that are waiting on the never-created channel.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "type Worker struct {\n    jobs chan Job\n}\nfunc NewWorker() *Worker {\n    return &Worker{jobs: make(chan Job, 16)}\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "var once sync.Once\nonce.Do(func() { close(w.jobs) })",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}