What happens internally when you send a value to a closed channel? What about receiving from a closed channel?

Last updated 20 June 2026

  • Sending on a closed channel panics (send on closed channel), so only the sender should close. Closing a closed or nil channel also panics.

  • Receiving drains remaining buffered values first, then returns the zero value immediately without blocking.

  • Detect closure with v, ok := <-ch (ok is false when closed and empty). A range loop exits cleanly on close.

  • https://www.reddit.com/r/rust/comments/1h15md8/goodbye_rust_i_wish_you_success_but_im_back_to_c/
  • https://www.reddit.com/r/golang/comments/1gfjnzm/since_when_is_senior_golang_developer_expected_to/
All Golang interview questions