# panic: receive from closed channel (in select)

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

## Root Cause

Selecting on a closed channel immediately receives zero values, which may cause unexpected behavior if not handled.

## Version Compatibility

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

## Workarounds

1. **Use two-value receive to check if channel is closed** (95% success)
   ```
   select {
case val, ok := <-ch:
    if !ok {
        // channel closed
    }
    // process val
}
   ```
2. **Set channel to nil after close to disable it** (85% success)
   ```
   close(ch)
ch = nil
select {
case <-ch: // blocked because nil
}
   ```

## Dead Ends

- **Ignoring closed channel in select** — Closed channel always returns zero value immediately; select may not behave as expected. (70% fail)
- **Using recover() to catch zero value** — Receive from closed channel doesn't panic; it returns zero value with ok=false. (90% fail)
