Does `go build`’s output flag `-o` have side-effects?

84 views Asked by At

From go build’s doc page:

The -o flag forces build to write the resulting executable or object to the named output file or directory, instead of the default behavior described in the last two paragraphs. If the named output is an existing directory or ends with a slash or backslash, then any resulting executables will be written to that directory.

However I’ve run into a building process that is essentially:

go build -o foo src/
mv foo bar

Is there any reason for doing this that I couldn’t find in documentation? E.g. does it set a linker symbol name to foo or something like that? Or is it just a quirk I can safely ignore?

1

There are 1 answers

0
Cimbali On BEST ANSWER

By looking at checksums of go build-generated binaries with the same sources and different -o flags, the files are absolutely identical. So there is no side effect.