# fatal error: all goroutines are asleep - deadlock! (nil channel)

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

## Root Cause

Sending to or receiving from a nil channel blocks forever, causing deadlock if all goroutines are stuck.

## Version Compatibility

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

## Workarounds

1. **Initialize channel before use** (99% success)
   ```
   var ch chan int
ch = make(chan int)
ch <- 42 // safe
   ```
2. **Use select with default to avoid blocking on nil channel** (85% success)
   ```
   select {
case ch <- val:
default:
    // handle nil or full channel
}
   ```

## Dead Ends

- **Checking channel with if ch != nil before operation** — Nil check is correct but often omitted due to oversight; still a logic error. (50% fail)
- **Using recover() to handle panic from nil channel** — Nil channel doesn't panic; it blocks forever, so recover is useless. (100% fail)
