Go Ring Buffer CLI
Go Ring Buffer — a runnable go project with source, install and run commands, and expected output.
Project
go-ring-buffer-cli
Entry point: main.go
Install
go run main.goRun
go run main.goTest
go testExpected output
Fixed-capacity ring buffer; pushes 5 items into size-3 and prints retained.Dependencies
- go >=1.22
Verification evidence
Source reviewed against go standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Go Ring Buffer CLI is a self-contained go command-line program. Fixed-capacity ring buffer; pushes 5 items into size-3 and prints retained.
Install and run
go run main.go
go run main.go
Project structure
go-ring-buffer-cli/
├── main.go
└── README snippet above
Key source
// main.go
package main
import "fmt"
type Ring struct{ a []int; n int }
func (r *Ring) Push(v int){ if len(r.a)<r.n { r.a=append(r.a,v); return }; r.a = append(r.a[1:], v) }
func main(){ r:=&Ring{n:3}; for i:=1;i<=5;i++ { r.Push(i) }; fmt.Println(r.a) }
Testing
go test
Expected output
When run with the documented command, the program prints:
[3 4 5]
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.