{
  "id": "go/channel-close-on-sender-panic",
  "signature": "panic: send on closed channel",
  "signature_zh": "恐慌：向已关闭的通道发送数据",
  "regex": "panic:\\ send\\ on\\ closed\\ channel",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Sending to a channel after it has been closed causes a runtime panic.",
  "root_cause_type": "generic",
  "root_cause_zh": "在通道关闭后向其发送数据会导致运行时恐慌。",
  "versions": [
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Recovery doesn't prevent data loss or inconsistency; the sender state is corrupted.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "len() doesn't indicate closed status; a closed channel can still have buffered items.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Mutex doesn't prevent closing while sending; race condition remains.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "ch := make(chan int)\nclose(ch)\n// Use select with a done channel to avoid sending after close\nselect {\ncase ch <- 1:\ndefault:\n    fmt.Println(\"channel closed\")\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "var mu sync.RWMutex\nclosed := false\n// In sender:\nmu.RLock()\nif !closed { ch <- 1 }\nmu.RUnlock()\n// In closer:\nmu.Lock()\nclose(ch)\nclosed = true\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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}