{
  "id": "go/channel-direction-mismatch",
  "signature": "panic: send on receive-only channel",
  "signature_zh": "恐慌：向只接收通道发送数据",
  "regex": "panic:\\ send\\ on\\ receive\\-only\\ channel",
  "domain": "go",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Attempting to send on a channel that is declared as receive-only (<-chan), or receive on a send-only channel (chan<-). This is a compile-time error, but can occur if type assertions are used incorrectly at runtime.",
  "root_cause_type": "generic",
  "root_cause_zh": "尝试向声明为只接收（<-chan）的通道发送数据，或在只发送（chan<-）通道上接收。这是编译时错误，但如果类型断言使用不当，可能在运行时发生。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Type assertions cannot change channel direction; it's a static property.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The program will panic or fail to compile.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "func producer(ch chan<- int) {\n    ch <- 1\n}\n\nfunc consumer(ch <-chan int) {\n    v := <-ch\n    fmt.Println(v)\n}\n\nch := make(chan int)\ngo producer(ch)\nconsumer(ch)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "ch := make(chan int)\n\ngo func(ch chan<- int) {\n    ch <- 42\n}(ch)\n\nv := <-ch\nfmt.Println(v)",
      "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-12-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}