https://github.com/cattlecloud/circlebuffer
A circular buffer implementation in Go with support for generics.
https://github.com/cattlecloud/circlebuffer
circular-buffer generic go golang library
Last synced: about 1 month ago
JSON representation
A circular buffer implementation in Go with support for generics.
- Host: GitHub
- URL: https://github.com/cattlecloud/circlebuffer
- Owner: cattlecloud
- License: bsd-3-clause
- Created: 2024-12-26T13:24:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-12-01T10:29:29.000Z (4 months ago)
- Last Synced: 2025-12-03T22:17:45.674Z (4 months ago)
- Topics: circular-buffer, generic, go, golang, library
- Language: Go
- Homepage: https://cattlecloud.net/go/circlebuffer
- Size: 16.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# circlebuffer
[](https://pkg.go.dev/cattlecloud.net/go/circlebuffer)
[](https://github.com/cattlecloud/circlebuffer/blob/main/LICENSE)
[](https://github.com/cattlecloud/circlebuffer/actions/workflows/ci.yaml)
`circlebuffer` provides a modern [circular buffer](https://en.wikipedia.org/wiki/Circular_buffer) Go library with support for generics.
### Getting Started
The `circlebuffer` package can be added to a project with `go-get`.
```shell
go get cattlecloud.net/go/circlebuffer@latest
```
```go
import "cattlecloud.net/go/circlebuffer"
```
### Examples
##### Inserting elements
```go
buf := circlebuffer.New[string](1024)
buf.Insert("alice")
buf.Insert("bob")
```
##### Iterating elements
```go
for item := range buf.All() {
// ...
}
```
### License
The `cattlecloud.net/go/circlebuffer` module is open source under the [BSD](LICENSE) license.