英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论