go compilation: remove personal info from executable

Viewed 431

I need to compile a go program for release and I have noticed that in the executable there are written all sort of personal information such as the original folder where the program is on my pc.

Is there a flag to avoid distributing all this "personal" bytes? Is it possible to rename all the function names during compilation?

thanks

2 Answers

Use the -trimpath argument to go build.

From go help build:

-trimpath

remove all file system paths from the resulting executable. Instead of absolute file system paths, the recorded file names will begin with either "go" (for the standard library), or a module path@version (when using modules), or a plain import path (when using GOPATH).

To answer your second question:

Is it possible to rename all the function names during compilation?

No, of course not.

(And you also cannot change the syscall numbers to obfuscate what your program does.)

((If you are trying to do fhishy stuff: Don't.))

Related