Go Streaming SHA-256 CLI
Go Streaming SHA-256 — a runnable go project with source, install and run commands, and expected output.
Project
go-sha256-stream-cli
Entry point: main.go
Install
go run main.go file.binRun
go run main.go sample.binTest
go testExpected output
Streams a file through sha256 and prints the hex digest.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 Streaming SHA-256 CLI is a self-contained go command-line program. Streams a file through sha256 and prints the hex digest.
Install and run
go run main.go file.bin
go run main.go sample.bin
Project structure
go-sha256-stream-cli/
├── main.go
└── README snippet above
Key source
// main.go
package main
import ("crypto/sha256"; "encoding/hex"; "fmt"; "io"; "os")
func main() {
f, _ := os.Open(os.Args[1]); h := sha256.New(); io.Copy(h, f)
fmt.Println(hex.EncodeToString(h.Sum(nil)))
}
Testing
go test
Expected output
When run with the documented command, the program prints:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
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.