{
  "id": "go/waitgroup-copied-by-value",
  "signature": "error: go vet: assignment copies lock value: sync.WaitGroup contains sync.noCopy",
  "signature_zh": "error：go vet：赋值复制了锁值：sync.WaitGroup 包含 sync.noCopy",
  "regex": "error:\\ go\\ vet:\\ assignment\\ copies\\ lock\\ value:\\ sync\\.WaitGroup\\ contains\\ sync\\.noCopy",
  "domain": "go",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "Passing a sync.WaitGroup by value copies its internal state; the copy's Done never reaches the original's Wait, so Wait hangs or panics.",
  "root_cause_type": "generic",
  "root_cause_zh": "按值传递 sync.WaitGroup 会复制其内部状态；副本的 Done 不会影响原始的 Wait，导致 Wait 挂起或 panic。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The copy shares no state; Done on the copy doesn't decrement the original counter, so Wait blocks forever.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The state is still split across two structs; the mutex does not merge them.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "func worker(wg *sync.WaitGroup) {\n    defer wg.Done()\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "type Pool struct { wg sync.WaitGroup }\nfunc (p *Pool) Add() { p.wg.Add(1) }",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}