{
  "id": "go/select-on-nil-channels",
  "signature": "fatal error: all goroutines are asleep - deadlock! (select with nil channels)",
  "signature_zh": "致命错误：所有 goroutine 都处于休眠状态 - 死锁！（选择包含 nil 通道）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(select\\ with\\ nil\\ channels\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A select statement with multiple cases where all channels are nil. In Go, a select with all nil channels blocks forever because no case can proceed.",
  "root_cause_type": "generic",
  "root_cause_zh": "一个选择语句有多个 case，但所有通道都是 nil。在 Go 中，所有通道都是 nil 的选择会永远阻塞，因为没有 case 可以执行。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding a default case to the select",
      "why_fails": "A default case will execute immediately if all channels are nil, but it doesn't solve the underlying issue of nil channels; it just avoids the block.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Removing the select and using direct channel operations",
      "why_fails": "Direct operations on nil channels will also block forever, so this doesn't help.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all channels in select are non-nil",
      "success_rate": 0.95,
      "how": "ch1 := make(chan int)\nch2 := make(chan int)\nselect {\ncase <-ch1:\ncase <-ch2:\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a helper function to filter out nil channels",
      "success_rate": 0.9,
      "how": "func nonNilChannels(chs ...chan int) []chan int {\n    var result []chan int\n    for _, ch := range chs {\n        if ch != nil {\n            result = append(result, ch)\n        }\n    }\n    return result\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-05-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}