{
  "id": "go/goroutine-select-nil-channel",
  "signature": "fatal error: all goroutines are asleep - deadlock! (select with all nil channels)",
  "signature_zh": "致命错误：所有协程都处于休眠状态 - 死锁！（所有通道都为 nil 的 select）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(select\\ with\\ all\\ nil\\ channels\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A select statement where all cases involve nil channels, causing the select to block forever.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个 select 语句，其中所有 case 都涉及 nil 通道，导致 select 永远阻塞。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "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": "Add a default case to select",
      "why_fails": "Default case will execute immediately, which may not be desired; also doesn't fix the nil channel issue.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Check each channel for nil before select",
      "why_fails": "Can become cumbersome; still need to handle nil channels properly.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Initialize all channels before select",
      "success_rate": 1.0,
      "how": "ch1 := make(chan int)\nch2 := make(chan int)\nselect {\ncase <-ch1:\ncase <-ch2:\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a non-nil channel as a sentinel",
      "success_rate": 0.9,
      "how": "ch := make(chan int)\nclose(ch) // closed channel always returns zero value\nselect {\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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}