# panic: close of closed channel

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

## Root Cause

Attempting to close a channel that has already been closed, usually due to multiple goroutines closing without coordination.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Use sync.Once to ensure the channel is closed only once.
   ```
2. **** (90% success)
   ```
   Have a single owner goroutine that is responsible for closing the channel.
   ```

## Dead Ends

- **** — The panic is fatal and cannot be recovered; it will crash the program. (90% fail)
- **** — Checking a flag is racy; the channel may be closed between the check and the close call. (85% fail)
- **** — The mutex ensures only one goroutine closes, but it does not prevent closing an already closed channel if the logic is wrong. (60% fail)
