{
  "id": "go/goroutine-racy-struct-field",
  "signature": "WARNING: DATA RACE: Write by goroutine X, Read by goroutine Y (struct field)",
  "signature_zh": "警告：数据竞争：协程X写入，协程Y读取（结构体字段）",
  "regex": "WARNING:\\ DATA\\ RACE:\\ Write\\ by\\ goroutine\\ X,\\ Read\\ by\\ goroutine\\ Y\\ \\(struct\\ field\\)",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Multiple goroutines accessing the same struct field without synchronization.",
  "root_cause_type": "generic",
  "root_cause_zh": "多个协程在没有同步的情况下访问同一个结构体字段。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using atomic operations on non-atomic types",
      "why_fails": "atomic.AddInt64 works only on int64; other types need different approach.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Copying struct before access",
      "why_fails": "Copy doesn't prevent race; original struct still accessed.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use mutex to protect struct field",
      "success_rate": 0.95,
      "how": "type Counter struct {\n    mu sync.Mutex\n    val int\n}\nfunc (c *Counter) Inc() {\n    c.mu.Lock()\n    c.val++\n    c.mu.Unlock()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use atomic.Value for struct",
      "success_rate": 0.85,
      "how": "var v atomic.Value\nv.Store(MyStruct{Field: 42})\ns := v.Load().(MyStruct)",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2026-03-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}