{
  "id": "go/send-on-closed-channel",
  "signature": "panic: send on closed channel",
  "signature_zh": "恐慌：向已关闭的通道发送数据",
  "regex": "panic:\\ send\\ on\\ closed\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Sending data to a channel that has been closed.",
  "root_cause_type": "generic",
  "root_cause_zh": "向已经关闭的通道发送数据。",
  "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": "Checking if channel is closed before sending via a flag",
      "why_fails": "Race condition: the channel may be closed between the check and the send.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using recover() to catch panic and continue",
      "why_fails": "Recovering from panic is possible but indicates design flaw; data may be lost.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure no sends after close by using a done channel pattern",
      "success_rate": 0.95,
      "how": "done := make(chan struct{})\n// producer loop\nselect {\ncase <-done:\n    return\ncase ch <- data:\n}\n// closer\nclose(ch); close(done)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a mutex to synchronize close and sends",
      "success_rate": 0.9,
      "how": "var mu sync.Mutex\nvar closed bool\nmu.Lock()\nif closed { mu.Unlock(); return }\nch <- data\nmu.Unlock()",
      "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-04-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}