July 2019
Intermediate to advanced
458 pages
12h 12m
English
There are many situations in which more than one goroutines are executing their code and communicating through channels. A typical scenario is to wait for one of the channels' send or receive operations to be executed.
When you operate with many channels, Go makes it possible to use a special keyword that executes something similar to switch but for channel operations. This is done with the select statement, followed by a series of case statements and an optional default case.
We can see a quick example of where we are receiving a value from a channel in a goroutine, and sending a value to another channel in a different goroutine. In these, the main goroutine we are using is a select statement to interact with ...
Read now
Unlock full access