The select Keyword

Let’s learn about the select keyword in Go.

Importance of the select keyword

The select keyword is really important because it allows us to listen to multiple channels at the same time. A select block can have multiple cases and an optional default case, which mimics the switch statement. It is good for select blocks to have a timeout option just in case. Last, a select without any cases (select{}) waits forever.

In practice, this means that select allows a goroutine to wait on multiple communication operations. So, select gives us the power to listen to ...