{
  "id": "go/goroutine-not-joining",
  "signature": "fatal error: all goroutines are asleep - deadlock! (main exits without waiting)",
  "signature_zh": "致命错误：所有 goroutine 都在休眠 - 死锁！（主函数未等待就退出）",
  "regex": "fatal\\ error:\\ all\\ goroutines\\ are\\ asleep\\ \\-\\ deadlock!\\ \\(main\\ exits\\ without\\ waiting\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Main function exits while other goroutines are still running, but they are blocked on channels or other operations, causing deadlock detection.",
  "root_cause_type": "generic",
  "root_cause_zh": "主函数退出时其他 goroutine 仍在运行，但它们阻塞在通道或其他操作上，导致死锁检测。",
  "versions": [
    {
      "version": "1.20",
      "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": "Sleep is nondeterministic; goroutines may finish later or never, and it's inefficient.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Program exits prematurely, possibly leaving resources unclean or missing results.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use sync.WaitGroup to wait for all goroutines to finish before returning from main.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use a done channel and close it when all work is done; main blocks on <-done.",
      "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-08-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}