finds.dev

smallnest/ringbuffer

a thread-safe circular buffer (ring buffer) in Go, implemented io.ReaderWriter interface

View on GitHub

★ 650GoMITupdated Oct 2026

// the take

A fixed-size, byte-oriented ring buffer for Go that implements io.ReadWriter (plus ReaderFrom/WriterTo), usable as either a non-blocking buffer or a drop-in async replacement for io.Pipe. Aimed at Go developers streaming data between a producer and consumer goroutine without the double-copy and allocation overhead of io.Copy.

Implementing the standard io interfaces directly (rather than a bespoke Push/Pop API) means it slots into existing pipelines that already expect an io.Reader/Writer. The Notify() channel is a genuinely useful addition for consumers that need to select on multiple events (new data, context cancellation, deadlines) without blocking inside Read — that's a real gap in the stdlib io.Pipe that this fills cleanly. Supporting both blocking and non-blocking modes on the same type (with WithDeadline for timeouts) covers two common use cases without forcing a choice of library. ReadFrom/WriterTo let you copy into or out of the buffer with zero intermediate allocation, which is the actual reason to reach for this over io.Copy with a plain pipe.

Despite being marketed as thread-safe, Notify explicitly only wakes one waiter per signal, so it only really supports a single-producer/single-consumer pattern — plug in multiple concurrent readers and you'll get missed wakeups, which is an easy footgun given the library's own claim. The buffer is fixed-size with no growth path; writes larger than the buffer in blocking mode wait indefinitely for reads to drain, so sizing it wrong under bursty load turns into a silent stall rather than a clear error. In blocking mode, errors set via CloseWithError are sticky and keep returning until you call Reset(), which is a subtly different contract than io.Pipe's one-shot EOF and will bite anyone porting code that assumes Pipe semantics. It's one of dozens of small utility packages from a prolific single maintainer, so there's no indication of a wider user base stress-testing edge cases beyond the author's own usage.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
650
Forks
71
Language
Go
License
MIT
Last commit
19 Oct 2026

// nearby

If ringbuffer isn't quite it.

All repos →