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

- **ID:** `go/waitgroup-reuse-before-wait`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

wg.Add is called again before a prior wg.Wait has returned, indicating the WaitGroup is being reused concurrently.

## Version Compatibility

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

## Workarounds

1. **** (94% success)
   ```
   for _, batch := range batches {
    var wg sync.WaitGroup
    for _, item := range batch {
        wg.Add(1)
        go func(i Item) { defer wg.Done(); work(i) }(item)
    }
    wg.Wait()
}
   ```
2. **** (90% success)
   ```
   g := new(errgroup.Group)
for _, item := range batch {
    g.Go(func() error { return work(item) })
}
g.Wait()
   ```

## Dead Ends

- **** — Sleep cannot guarantee goroutine completion and reintroduces races. (80% fail)
- **** — Reassigning wg while goroutines hold a reference to the old one causes Done to target the wrong counter. (75% fail)
