Reputation: 11
Initially my module consisted of both backend and frontend. When putting into an executable, cmd opened up, but with the -ldflags "-H windowsgui"
it went away. Eventually, I wanted backend and frontend to be independent from each other, so I finally separated them and imported my backend as a private github repo in frontend module. With go run main.go
it's working fine, however when compiling into an executable the cmd shows up every time backend logs something (i.e. prints), no matter the flag. Without the windowsgui
flag the cmd shows up instantly and just stays there, with the flag it shows up when backend does something, disappears, appears again, etc.
There are almost no answers relating to this on Google, but I tried everything I saw: putting the flags in the go get, changing the flag to -ldflags=all=-H=windowsgui
, clearing modcache every time, putting the build comment on the top of main file, nothing worked for me so far. So, what I expect is no cmd showing up when I execute and use my built binary file with go build
.
Upvotes: 1
Views: 47