{
  "id": "go/goroutine-leak-without-waitgroup",
  "signature": "warning: goroutine leak detected (in goroutine 5)",
  "signature_zh": "警告：检测到 goroutine 泄漏（在 goroutine 5 中）",
  "regex": "warning:\\ goroutine\\ leak\\ detected\\ \\(in\\ goroutine\\ 5\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Goroutines that never exit due to blocked channel operations or infinite loops leak memory.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于通道操作阻塞或无限循环而永不退出的 goroutine 会导致内存泄漏。",
  "versions": [
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "GC doesn't collect goroutines; they are not garbage.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Temporary mitigation; eventually memory exhausts.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaks accumulate, causing OOM crashes.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var wg sync.WaitGroup\nwg.Add(1)\ngo func() {\n    defer wg.Done()\n    // do work\n}()\nwg.Wait()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ctx, cancel := context.WithCancel(context.Background())\ngo func() {\n    select {\n    case <-ctx.Done():\n        return\n    case <-time.After(time.Second):\n        // work\n    }\n}()\ncancel()",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}