Summary
In this chapter, we learned how to share data by communicating between the channels. We started by looking at the syntax for defining unbuffered and buffered channels. Later, we learned how to perform push and pop operations on the channel using the <-
arrow operator. We then learned about the various properties that are available on channel variables. We also learned how to use the try_push()
, try_pop()
and close()
channel methods.
Later, we learned how to work with unbuffered channels by writing a code example in V, and we also understood the blocking nature of unbuffered channels and how to deal with them. We then covered how to synchronize data between the coroutines of an unbuffered channel. Similarly, we learned how to work with buffered channels and their behavior by looking at code examples.
Finally, we looked at how to work with the select
statement and wrote channel operations that became part of the conditional branches of the select
statement. Having learned...