# panic: close of nil channel

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

## Root Cause

Attempting to close a channel that has not been initialized (nil).

## Version Compatibility

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

## Workarounds

1. **** (98% success)
   ```
   ch := make(chan int)
// later
close(ch)
   ```
2. **** (90% success)
   ```
   var once sync.Once
closeCh := func() {
    if ch != nil {
        once.Do(func() { close(ch) })
    }
}
   ```

## Dead Ends

- **** — If the channel is nil, closing it is still a panic; you must avoid the close entirely (80% fail)
- **** — Recovering hides the bug and may leave resources in inconsistent state (70% fail)
