# fatal error: all goroutines are asleep - deadlock! (select with nil channels)

- **ID:** `go/select-on-nil-channels`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A select statement with multiple cases where all channels are nil. In Go, a select with all nil channels blocks forever because no case can proceed.

## Version Compatibility

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

## Workarounds

1. **Ensure all channels in select are non-nil** (95% success)
   ```
   ch1 := make(chan int)
ch2 := make(chan int)
select {
case <-ch1:
case <-ch2:
}
   ```
2. **Use a helper function to filter out nil channels** (90% success)
   ```
   func nonNilChannels(chs ...chan int) []chan int {
    var result []chan int
    for _, ch := range chs {
        if ch != nil {
            result = append(result, ch)
        }
    }
    return result
}
   ```

## Dead Ends

- **Adding a default case to the select** — A default case will execute immediately if all channels are nil, but it doesn't solve the underlying issue of nil channels; it just avoids the block. (80% fail)
- **Removing the select and using direct channel operations** — Direct operations on nil channels will also block forever, so this doesn't help. (95% fail)
