{
  "id": "go/data-race-on-variable",
  "signature": "WARNING: DATA RACE - Write at 0x00c000012345 by goroutine 6",
  "signature_zh": "警告：数据竞争 - goroutine 6 在地址 0x00c000012345 写入",
  "regex": "WARNING:\\ DATA\\ RACE\\ \\-\\ Write\\ at\\ 0x00c000012345\\ by\\ goroutine\\ 6",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Concurrent reads and writes to a shared variable without synchronization.",
  "root_cause_type": "generic",
  "root_cause_zh": "并发读写共享变量而没有同步。",
  "versions": [
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Reads still race unless also atomic.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Go doesn't have volatile; no effect.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Sleep doesn't establish happens-before relationship.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var mu sync.Mutex\nvar x int\n// Write\nmu.Lock()\nx = 1\nmu.Unlock()\n// Read\nmu.Lock()\n_ = x\nmu.Unlock()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "var x atomic.Int32\nx.Store(1)\n_ = x.Load()",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}