By convention, who is responsible for closing a channel, and why should receivers never close a channel?

Last updated 20 June 2026

  • The sender closes the channel because only it knows no more values are coming. Closing lets receivers drain remaining values and end a range loop (or get ok == false).

  • Receivers must not close: sending on a closed channel panics, and so does closing twice. A receiver also can't know if other senders are still active.

  • With multiple senders, use a sync.WaitGroup and a separate goroutine that closes after all finish. Closing is only needed to signal receivers (GC frees channels anyway).

  • https://www.freecodecamp.org/news/learn-golang-handbook/
  • https://dev.to/nazar_boyko/how-to-prepare-for-a-golang-interview-a-practical-guide-for-mid-senior-engineers-200p
  • https://www.freecodecamp.org/news/how-to-handle-concurrency-in-go/
All Golang interview questions