{
  "id": "go/nil-channel-blocks-forever",
  "signature": "error: select on nil channel blocks forever",
  "signature_zh": "错误：在 nil 通道上的 select 永久阻塞",
  "regex": "error:\\ select\\ on\\ nil\\ channel\\ blocks\\ forever",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Sending to or receiving from a nil channel blocks forever. In a select, a nil channel case is never ready, so if all cases are nil, the select blocks indefinitely.",
  "root_cause_type": "generic",
  "root_cause_zh": "向 nil 通道发送或从 nil 通道接收会永久阻塞。在 select 中，nil 通道分支永远不会就绪，若所有分支都是 nil，select 会无限阻塞。",
  "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"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "With default, the select always takes the default branch, so nothing ever happens; the intended wait is lost.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The outer select still holds the nil reference; the goroutine's new channel is unrelated.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var ch chan int = make(chan int)\nselect {\ncase v := <-ch: _ = v\ncase <-time.After(time.Second):\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "var never chan struct{} // nil disables the case\nselect {\ncase <-never:\ncase <-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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}