Is it OK to leave a channel open?

It’s OK to leave a Go channel open forever and never close it. When the channel is no longer used, it will be garbage collected.

Note that it is only necessary to close a channel if the receiver is
looking for a close. Closing the channel is a control signal on the
channel indicating that no more data follows.

Design Question: Channel Closing

Leave a Comment