添加一个命令来进行构建。

huangapple go评论65阅读模式
英文:

Adding a command to go build

问题

我有一个在所有操作系统(Windows、macOS、Linux、FreeBSD)上都可以运行的项目。然而,当构建二进制文件并在Windows上运行时,命令提示符会随之打开。我想自动添加"-ldflag -H=windowsgui"作为go build的参数,但我不确定如何添加。

英文:

I have a project that works across all os (windows, macos, Linux, freeBSD). However when the binary is built, and run on windows, the command prompt opens up with it. I would like to automatically add -ldflag -H=windowsgui as an argument to go build but I am not sure how to add it

答案1

得分: 2

我通常使用批处理文件来完成这个任务!

go build -v -o main.exe -ldflags -H=windowsgui
main.exe

然后我只需运行build.bat。

对于其他操作系统,你可以使用类似于这样的.sh脚本。

英文:

I usually use a bat file for that!

go build -v -o main.exe -ldflags -H=windowsgui
main.exe

Then I just run build.bat .

For other OSes, you could use a .sh script similar to this.

huangapple
  • 本文由 发表于 2022年6月8日 14:41:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/72541134.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定