# panic: sync: WaitGroup is reused before previous Wait has returned

- **ID:** `go/panic-waitgroup-misuse-add-inside-goroutine`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

wg.Add is called after wg.Wait has returned, or Add is called inside a goroutine racing with Wait.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.0+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   wg.Add(len(items))
for _, it := range items {
    go func(x Item) { defer wg.Done(); process(x) }(it)
}
wg.Wait()
   ```
2. **** (93% success)
   ```
   g := new(errgroup.Group)
for _, it := range items {
    it := it
    g.Go(func() error { return process(it) })
}
return g.Wait()
   ```

## Dead Ends

- **** — Races with Wait; Wait may observe zero counter and return early. (90% fail)
- **** — WaitGroup is not designed for reuse until Wait returns; runtime panics. (85% fail)
