{
  "id": "go/goroutine-close-nil-channel",
  "signature": "panic: close of nil channel",
  "signature_zh": "恐慌：关闭nil通道",
  "regex": "panic:\\ close\\ of\\ nil\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling close() on a nil channel, which is a programming error.",
  "root_cause_type": "generic",
  "root_cause_zh": "对nil通道调用close()，这是编程错误。",
  "versions": [
    {
      "version": "1.0",
      "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": "Using recover() to catch panic",
      "why_fails": "Recover works but doesn't fix the logic; channel remains nil.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Checking ch != nil before close but not initializing",
      "why_fails": "Nil check prevents panic but channel is never initialized; subsequent operations fail.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize channel before close",
      "success_rate": 0.99,
      "how": "ch := make(chan int)\n// use ch\nclose(ch)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Once to safely close only if initialized",
      "success_rate": 0.85,
      "how": "var once sync.Once\nif ch != nil {\n    once.Do(func() { close(ch) })\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": "2025-05-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}