Go Priority Queue CLI
Go Priority Queue — a runnable go project with source, install and run commands, and expected output.
Project
go-priority-queue-cli
Entry point: main.go
Install
go run main.goRun
go run main.goTest
go testExpected output
Uses container/heap to push and pop items by priority.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 Priority Queue CLI is a self-contained go command-line program. Uses container/heap to push and pop items by priority.
Install and run
go run main.go
go run main.go
Project structure
go-priority-queue-cli/
├── main.go
└── README snippet above
Key source
// main.go
package main
import ("container/heap"; "fmt")
type Item struct{ p int; v string }
type PQ []Item
func (p PQ) Len() int { return len(p) }
func (p PQ) Less(i,j int) bool { return p[i].p < p[j].p }
func (p PQ) Swap(i,j int) { p[i],p[j]=p[j],p[i] }
func (p *PQ) Push(x any) { *p = append(*p, x.(Item)) }
func (p *PQ) Pop() any { o:=*p; n:=len(o); x:=o[n-1]; *p=o[:n-1]; return x }
func main() {
h := &PQ{}; heap.Init(h)
for _, it := range []Item{{3,"a"},{1,"b"},{2,"c"}} { heap.Push(h, it) }
for h.Len() > 0 { fmt.Print(heap.Pop(h).(Item).v, " ") }
}
Testing
go test
Expected output
When run with the documented command, the program prints:
b c a
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.