← Runnable Projects

阅读中文版本

Go Hexdump CLI

Go Hexdump — a runnable go project with source, install and run commands, and expected output.

intermediategounverified

Project

go-hexdump-cli

Entry point: main.go

Install

go run main.go file.bin

Run

go run main.go sample.bin

Test

go test

Expected output

Prints an offset + hex + ASCII dump of a binary file.

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 Hexdump CLI is a self-contained go command-line program. Prints an offset + hex + ASCII dump of a binary file.

Install and run

go run main.go file.bin
go run main.go sample.bin

Project structure

go-hexdump-cli/
├── main.go
└── README snippet above

Key source

// main.go
package main
import ("fmt"; "os")
func main() {
    b, _ := os.ReadFile(os.Args[1])
    for i := 0; i < len(b); i += 16 {
        e := i+16; if e > len(b) { e = len(b) }
        fmt.Printf("%08x  % x  |%s|\n", i, b[i:e], ascii(b[i:e]))
    }
}
func ascii(b []byte) string { s := make([]byte, len(b)); for i,c := range b { if c>=32&&c<127 { s[i]=c } else { s[i]=46 } }; return string(s) }

Testing

go test

Expected output

When run with the documented command, the program prints:

00000000  68 65 6c 6c 6f  |hello|

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.