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
CodePudding user response:
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.