-trimpath
A go build flag that removes the folder paths of your machine from the compiled binary.
In more detail
Without it, file paths from the build machine appear in the binary, for example in panic messages. Removing them hides local details and helps two machines produce identical output from the same source, which supports reproducible builds.
Example
go build -trimpath -o app .Related terms
- linker flags — Options passed to the Go linker through go build -ldflags, commonly used to strip debugging symbols or stamp a version into the binary.
- reproducible build — A build that produces the same result every time from the same inputs.
- go build — The go subcommand that compiles a package and its dependencies into an executable file and prints nothing when it succeeds.
Taught in
- Building Static Binaries — Concurrent Systems Programming with Go