Go CSV Stats CLI
Go CSV Stats — a runnable go project with source, install and run commands, and expected output.
Project
go-csv-stats-cli
Entry point: main.go
Install
go run main.go data.csvRun
go run main.go sample.csvTest
go testExpected output
Reads CSV rows and prints count and mean of a numeric column.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 CSV Stats CLI is a self-contained go command-line program. Reads CSV rows and prints count and mean of a numeric column.
Install and run
go run main.go data.csv
go run main.go sample.csv
Project structure
go-csv-stats-cli/
├── main.go
└── README snippet above
Key source
// main.go
package main
import ("encoding/csv"; "fmt"; "os"; "strconv")
func main() {
f, _ := os.Open(os.Args[1]); r := csv.NewReader(f)
var sum, n float64
for {
rec, e := r.Read(); if e != nil { break }
v, _ := strconv.ParseFloat(rec[1], 64); sum += v; n++
}
fmt.Printf("count=%.0f mean=%.2f\n", n, sum/n)
}
Testing
go test
Expected output
When run with the documented command, the program prints:
count=3 mean=2.00
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.