In Chapter 2, Understanding Goroutines, we looked at how goroutines work, how to use them in a concurrent fashion, and some of the common mistakes that might occur. They were simple to use and reason about, but they were limited because they are able to spawn other goroutines and wait on system calls. In reality, goroutines are more capable than what was shown in the previous chapter, and to uncover their full potential we need to understand how to use channels, which is the aim of the current chapter. Here, we will look at the following topics:
- Controlling parallelism
- Channels and data communication
- Types of channels
- Closing and multiplexing channels