← Runnable Projects

阅读中文版本

Go Base32 Codec CLI

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

intermediategounverified

Project

go-base32-cli

Entry point: main.go

Install

go run main.go encode hello

Run

go run main.go encode hello

Test

go test

Expected output

Encodes a string to base32 (std encoding) and prints it.

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 Base32 Codec CLI is a self-contained go command-line program. Encodes a string to base32 (std encoding) and prints it.

Install and run

go run main.go encode hello
go run main.go encode hello

Project structure

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

Key source

// main.go
package main
import ("encoding/base32"; "fmt"; "os")
func main() {
    op, s := os.Args[1], os.Args[2]
    if op == "encode" {
        fmt.Println(base32.StdEncoding.EncodeToString([]byte(s)))
    } else {
        b, _ := base32.StdEncoding.DecodeString(s)
        fmt.Println(string(b))
    }
}

Testing

go test

Expected output

When run with the documented command, the program prints:

NBSWY3DP===   (base32 of "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.