# panic: race detected during execution of test

- **ID:** `go/race-detector-in-test`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A test running under -race spawns goroutines that share state without synchronization, and the race detector aborts the test binary.

## Version Compatibility

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

## Workarounds

1. **** (92% success)
   ```
   var wg sync.WaitGroup
wg.Add(1)
go func() { defer wg.Done(); mutateShared() }()
wg.Wait()
   ```
2. **** (90% success)
   ```
   go test -race -run TestFoo ./...
// read the two conflicting stacks and add a mutex around both
   ```

## Dead Ends

- **** — Shuffling changes timing but the unsynchronized access remains and the race recurs. (80% fail)
- **** — The race is inside the test's own goroutines, not between tests, so serializing tests does not help. (75% fail)
