O'Reilly logo

Distributed Computing with Go by V.N. Nikhil Anurag

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The unidirectional buffer

Messages can be sent and received from a channel. However, when goroutines use channels for communication, they are generally going to be for a single purpose: either to send or receive from a channel. Go allows us to specify whether a channel being used by a goroutine is for sending or receiving messages. It accomplishes this with the help of unidirectional channels. Once a channel has been identified as being unidirectional, we cannot perform the other operation on them. This means that a unidirectional send channel cannot be used to receive messages, and a unidirectional receive channel cannot be used to send messages. Any attempts to do so would be caught by the Go compiler as compile-time errors.

Here is an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required