3 Golang Channel Red Flags

Red Flag 1: More Than One close() When reviewing code that uses channels, first thing I do is search for close() on every channel. More than one close() is red flag because, unless all uses of the channel are carefully written and tested, it can lead to a panic on close of closed channel. It can also lead to strange behavior or subtle bugs because the code that didn’t close the channel isn’t aware the channel is closed, so send and receive on the closed channel don’t have the intended effect. Read more...