-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

Taught in

References