{
  "id": "go/goroutine-channel-close-multiple",
  "signature": "panic: close of closed channel",
  "signature_zh": "恐慌：关闭已关闭的通道",
  "regex": "panic:\\ close\\ of\\ closed\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling close() on a channel that has already been closed, typically due to multiple goroutines attempting to close the same channel.",
  "root_cause_type": "generic",
  "root_cause_zh": "对已经关闭的通道再次调用close()，通常是由于多个协程试图关闭同一个通道。",
  "versions": [
    {
      "version": "1.21",
      "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": "Checking if channel is closed before closing",
      "why_fails": "No built-in way to check if a channel is closed without risking a race condition.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover() to catch panic",
      "why_fails": "Recover does not prevent the panic from occurring; it only catches it after the fact.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use sync.Once to ensure close is called only once",
      "success_rate": 0.99,
      "how": "var closeOnce sync.Once\ncloseOnce.Do(func() {\n    close(ch)\n})",
      "condition": "",
      "sources": []
    },
    {
      "action": "Designate a single goroutine to close the channel",
      "success_rate": 0.98,
      "how": "// Only one goroutine has access to close(ch)\nch := make(chan int)\ngo func() {\n    // close when done\n    close(ch)\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": "2025-03-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}