A circular buffer (ring buffer) in Go, implementing standard Go interfaces for reads and writes.
rb := New(1024)
// write
rb.Write([]byte("abcd"))
fmt.Println(rb.Length())
fmt.Println(rb.Free())
// read
buf := make([]byte, 4)
rb.Read(buf)
fmt.Println(string(buf))
Copyright (c) 2019 smallnest, 2023 Ananth Bhaskararaman
ringbuffer is available under the terms of the MIT license.