{
  "id": "go/channel-close-twice",
  "signature": "panic: close of closed channel",
  "signature_zh": "恐慌：关闭已关闭的通道",
  "regex": "panic:\\ close\\ of\\ closed\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Attempting to close a channel that has already been closed, usually due to multiple goroutines closing without coordination.",
  "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": "",
      "why_fails": "The panic is fatal and cannot be recovered; it will crash the program.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Checking a flag is racy; the channel may be closed between the check and the close call.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The mutex ensures only one goroutine closes, but it does not prevent closing an already closed channel if the logic is wrong.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use sync.Once to ensure the channel is closed only once.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Have a single owner goroutine that is responsible for closing the channel.",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-28",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}