去编译:从可执行文件中删除个人信息

go compilation: remove personal info from executable

我需要编译一个 go 程序发布,我注意到在可执行文件中写入了各种个人信息,例如程序在我的电脑上的原始文件夹。

是否有标志来避免分发所有这些 "personal" 字节? 是否可以在编译过程中重命名所有函数名称?

谢谢

-trimpath 参数用于 go build

来自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).

回答你的第二个问题:

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

不,当然不是。

(而且您也不能更改系统调用编号来混淆您的程序的功能。)

((如果你想做鱼腥味的东西:不要。))