{
  "id": "go/deadlock-on-unbuffered-channel-send",
  "signature": "fatal error: all goroutines are asleep - deadlock!",
  "signature_zh": "致命错误：所有 goroutine 都处于休眠状态 - 死锁！",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Sending on an unbuffered channel without a corresponding receiver in the same goroutine causes a deadlock.",
  "root_cause_type": "generic",
  "root_cause_zh": "在同一 goroutine 中向无缓冲通道发送数据而没有对应的接收者会导致死锁。",
  "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding a small sleep before sending",
      "why_fails": "Sleep does not create a receiver; the send still blocks indefinitely.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a buffered channel with capacity 1 but still no receiver",
      "why_fails": "Buffered channel only helps if capacity is not exceeded; if no receiver, the send blocks after buffer fills.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure a separate goroutine receives from the channel before sending",
      "success_rate": 0.95,
      "how": "go func() { <-ch }(); ch <- data",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a buffered channel with sufficient capacity",
      "success_rate": 0.9,
      "how": "ch := make(chan int, 1); ch <- 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-01-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}