{
  "id": "go/channel-leak-without-close",
  "signature": "warning: channel leak detected (chan int, goroutine 3)",
  "signature_zh": "警告：检测到通道泄漏（chan int，goroutine 3）",
  "regex": "warning:\\ channel\\ leak\\ detected\\ \\(chan\\ int,\\ goroutine\\ 3\\)",
  "domain": "go",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "A channel is never closed and no goroutine is sending or receiving, causing it to be held forever.",
  "root_cause_type": "generic",
  "root_cause_zh": "通道从未关闭，且没有 goroutine 发送或接收，导致其永远被持有。",
  "versions": [
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Channels are not garbage collected if referenced; GC doesn't force close.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Nil channel blocks forever; doesn't release resources.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaks accumulate, leading to memory exhaustion.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ch := make(chan int)\n// Ensure it's closed eventually\ndefer close(ch)\n// or use a worker that exits",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "ctx, cancel := context.WithCancel(context.Background())\nch := make(chan int)\ngo func() {\n    select {\n    case <-ctx.Done():\n        close(ch)\n    case v := <-ch:\n        // process\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.8,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}