Skip to main content

Gist 309734

✓ Published0🌍 Public
Aaht
Last edited Feb 20, 2010
Created on Feb 20, 2010

This example demonstrates a non-blocking channel proxy in Go using `container/ring` to implement an auto-expanding circular buffer. It shows how a goroutine continuously drains an input channel into a ring buffer while another goroutine forwards values to an output channel, never blocking the sender. The code uses `ring.New`, `Link`, and `Next` to manage buffer growth, doubling the ring size when full, and closes the output channel when the input is closed and drained. The visualization highlights the dynamic queue expansion and channel synchronization behavior through the `sendproxy` function.

AI-generated description