{
  "id": "go/nil-channel-send",
  "signature": "panic: runtime error: send on nil channel",
  "signature_zh": "恐慌：运行时错误：向空通道发送数据",
  "regex": "panic:\\ runtime\\ error:\\ send\\ on\\ nil\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to send on a channel that is nil (not initialized with make)",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试向未使用make初始化的空通道发送数据",
  "versions": [
    {
      "version": "1.18",
      "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 a global variable without initialization",
      "why_fails": "Global channel variables default to nil; forgetting to initialize with make leads to panic",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Assuming channel is initialized after function returns",
      "why_fails": "If the channel is assigned inside a goroutine, it may still be nil when another goroutine tries to send",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize channel with make before any send operation",
      "success_rate": 0.95,
      "how": "ch := make(chan int, 10)\nch <- 42",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use sync.Once to ensure channel initialization is done once",
      "success_rate": 0.9,
      "how": "var once sync.Once\nvar ch chan int\nonce.Do(func() {\n    ch = make(chan int)\n})\nch <- 42",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}