There is an alternative solution for this, using the "queue" process, which processes the message queue and can also report its size. To do this, you will need an input channel and an output channel, as well as a request channel through which the size will be obtained. Since there will be two input channels, you will need a choice (CSP selection) between them.
Here's a little demonstration of this in action. The queue consists of a slice as a buffer and an input channel.
func queue(in <-chan string, out chan<- string, query <-chan chan int) { buffer := []string{} var s string var reply chan int for {
source share