# panic: close of nil channel

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

## Root Cause

close() was called on a channel variable that was never initialized with make() or was set to nil, typically after a failed conditional assignment.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   type Worker struct {
    jobs chan Job
}
func NewWorker() *Worker {
    return &Worker{jobs: make(chan Job, 16)}
}
   ```
2. **** (90% success)
   ```
   var once sync.Once
once.Do(func() { close(w.jobs) })
   ```

## Dead Ends

- **** — This masks the real bug: the channel was supposed to be created. Downstream senders/receivers now block forever on a nil channel instead of panicking, turning a crash into a hang. (70% fail)
- **** — Hides the defect and leaks the goroutines that are waiting on the never-created channel. (85% fail)
