{
  "id": "go/nil-channel-block-forever",
  "signature": "fatal error: all goroutines are asleep - deadlock! (goroutine 1 [chan receive (nil chan)])",
  "signature_zh": "致命错误：所有 goroutine 都处于休眠状态 - 死锁！（goroutine 1 [通道接收（nil 通道）]）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(goroutine\\ 1\\ \\[chan\\ receive\\ \\(nil\\ chan\\)\\]\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Sending or receiving on a nil channel blocks forever. This happens when a channel variable is not initialized before use.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 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": "The default case may execute incorrectly, and the nil channel still blocks if not handled properly.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Nil channel is a different type; assigning doesn't initialize it.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "ch := make(chan int) // or with buffer: make(chan int, 10)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "var ch chan int\nselect {\ncase v := <-ch:\n    // will not execute if ch is nil\ncase <-time.After(time.Second):\n    // handle timeout\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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}