{
  "id": "go/data-race-detected",
  "signature": "WARNING: DATA RACE\nWrite at 0x00c0000... by goroutine N:",
  "signature_zh": "警告: 数据竞争\n地址 0x00c0000... 的写入由 goroutine N 执行:",
  "regex": "WARNING:\\ DATA\\ RACE\\\nWrite\\ at\\ 0x00c0000\\.\\.\\.\\ by\\ goroutine\\ N:",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Two goroutines access the same memory location concurrently, at least one is a write, and there is no synchronization; detected when running with -race.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个 goroutine 并发访问同一内存位置，其中至少一个是写操作，且没有同步；在使用 -race 运行时被检测到。",
  "versions": [
    {
      "version": "1.1+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides the symptom; the race still corrupts data in production and can cause random crashes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Atomic on only one side does not establish a happens-before relationship; the race persists.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "Protect the shared variable with sync/atomic:\natomic.AddInt64(&counter, 1)\nv := atomic.LoadInt64(&counter)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Guard the critical section with a sync.Mutex and keep the section minimal.",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}