This is a creation in Article, where the information may have evolved or changed.
The call to cmd command via the Go Standard library exec will flash the Black window, in order to resolve this issue under Windows can be used with the Win32 API WinExec.
This problem occurs primarily when a program that has a UI or no console calls CMD.
Add parameters when compiling go: Go build-ldflags= "-H Windowsgui"
Package Mainimport ("Errors" "Log") Import ("Github.com/codyguo/win") var (winexecerror = map[uint32]string{0: "the System is out of memory or resources. ", 2: " the. exe file is invalid. ", 3: " The specified file was not found. ", 11:" The specified path is not found. ",}) Func main () {err: = Execrun (" cmd/c start http://www.baidu.com ") if err! = Nil {log. Fatal (Err)}}func execrun (cmd string) error {lpCmdLine: = win. Stringtobyteptr (CMD)//Http://baike.baidu.com/link?url=51sQomXsIt6OlYEAV74YZ0JkHDd2GbmzXcKj_ 4h1r4ilxvqnf3mxiscknaksr93e7fyns4itmsatdycebhrxzqret: = win. WinExec (lpCmdLine, win.sw_hide) if RET <= {return errors. New (Winexecerror[ret])}return Nil}