
How to Test Go CLI Tools With Table Driven Tests Properly
Test Go command line tools with table driven tests: a testable run function, in-memory streams, subtests, temp directories and a real binary test.
Tag
5 posts

Test Go command line tools with table driven tests: a testable run function, in-memory streams, subtests, temp directories and a real binary test.

Fix exec format error with Go binaries: GOOS and GOARCH mismatches, building on Mac for Linux, Docker platform flags, and how to check a binary with file.

Fix the Go error exec executable file not found in PATH: why exec.Command needs the program on PATH, LookPath, absolute paths, containers and services.

Compare Cobra, urfave/cli and Kong for Go command line tools: how each declares commands, flags, help and completions, and which fits which project.

Why Go binaries are large and how to shrink them: ldflags -s -w, trimpath, UPX trade-offs, dropping heavy dependencies and measuring what takes space.