# panic: receive from closed channel

- **ID:** `go/goroutine-receive-from-closed-channel`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to receive from a channel that was closed while a goroutine is waiting, but the panic occurs only if the channel is nil.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.18 | active | — | — |
| 1.19 | active | — | — |
| 1.20 | active | — | — |
| 1.21 | active | — | — |
| 1.22 | active | — | — |

## Workarounds

1. **Use comma-ok idiom to detect closed channel** (95% success)
   ```
   v, ok := <-ch; if !ok { /* channel closed */ }
   ```
2. **Ensure channel is not nil before receive** (80% success)
   ```
   if ch != nil { v := <-ch }
   ```

## Dead Ends

- **Checking channel with cap() before receive** — cap() does not indicate closed state. (90% fail)
- **Using recover() to ignore panic** — Recover does not prevent data corruption. (70% fail)
