{
  "id": "go/panic-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() is called on a channel variable that was never initialized with make(), so it holds the nil zero value.",
  "root_cause_type": "generic",
  "root_cause_zh": "对一个从未用 make() 初始化的 channel 变量调用 close()，其值为 nil 零值。",
  "versions": [
    {
      "version": "1.18",
      "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": "",
      "why_fails": "Skipping the close leaves the channel open forever, so receivers block indefinitely; the underlying logic bug remains.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Creating a fresh channel at close time means no other goroutine holds a reference to it; the close is meaningless.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Initialize the channel at declaration: ch := make(chan int). Never use var ch chan int without assignment if it will be closed.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "Use a struct constructor that always makes the channel, e.g. func NewWorker() *Worker { return &Worker{jobs: make(chan Job)} }.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}