# Go: panic: send on closed channel

**Code:** `panic: send on closed channel` · **Category:** Go · **Seen on:** Go

A goroutine sent a value to a channel after it had been closed.

## Meaning

Only the sender (or a single coordinating owner) should close a channel, never the receiver, and never while other goroutines might still send. Use a `sync.WaitGroup` to wait for all senders before closing, or signal shutdown with a separate `done` channel/context.

## Common causes

- Closing from the receiver side
- Multiple senders and one closes early
- Close before all senders finish
- Shutdown path racing with producers
- Reusing a closed channel

## Quick fix

1. Let the producer close after all sends finished
2. `wg.Wait(); close(ch)` in a coordinator goroutine
3. Use `context.Context` for cancellation instead of closing a shared channel

## Detailed fix by platform

### Go

1. `go func(){ wg.Wait(); close(results) }()`

## How to diagnose

1. **Owner** — Who closes?
2. **Senders** — Still running?
3. **Signal** — Use context?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/send-on-closed-channel)
