Go provides us with three major variations on channel types. They can be broadly classified into:
- Unbuffered
- Buffered
- Unidirectional (send-only and receive-only type channels)
Go provides us with three major variations on channel types. They can be broadly classified into:
This is the basic channel type available in Go. It is quite straightforward to use—we send data into the channel and we receive data at the other end. The interesting part is that any goroutine operating on an unbuffered channel will be blocked until both the sender and receiver goroutines are available. For example, consider the following code snippet:
ch := make(chan int) go func() {ch <- 100} // Send 100 into channel.
Channel: send100 go...