# WARNING: DATA RACE: Write by goroutine X, Read by goroutine Y (channel close)

- **ID:** `go/goroutine-racy-channel-close`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Multiple goroutines trying to close the same channel without synchronization, causing race.

## Version Compatibility

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

## Workarounds

1. **Use sync.Once to ensure close is called only once** (95% success)
   ```
   var once sync.Once
once.Do(func() { close(ch) })
   ```
2. **Use a dedicated closer goroutine** (85% success)
   ```
   closeCh := make(chan struct{})
go func() {
    <-closeCh
    close(ch)
}()
// signal close
close(closeCh)
   ```

## Dead Ends

- **Using atomic flag to guard close** — Close itself is not atomic; still race between check and close. (80% fail)
- **Using recover() to catch double close panic** — Recover doesn't prevent race; panic may still occur. (90% fail)
