go build -ldflags -H=windowsgui main.go
or
go build -ldflags "-H windowsgui" main.go
package main
import "github.com/gonutz/w32/v2"
func main() {
console := w32.GetConsoleWindow()
if console != 0 {
_, consoleProcID := w32.GetWindowThreadProcessId(console)
if w32.GetCurrentProcessId() == consoleProcID {
w32.ShowWindowAsync(console, w32.SW_HIDE)
}
}
}