dqd78456 2014-04-23 16:43
浏览 257
已采纳

如何从Golang创建可执行文件,该可执行文件在运行时不会打开命令(cmd)窗口?

I created an application that I want to run invisibly in the background (no command / cmd console). How do I do this?

(This is for Windows, tested on Windows 7 Pro 64 bit)

  • 写回答

3条回答 默认 最新

  • duanqiao1880 2014-04-23 16:43
    关注

    The documentation found online says I can compile with something along the lines of,

    go build -ldflags -Hwindowsgui filename.go

    But this gives an error: unknown flag -Hwindowsgui

    With more recent (1.1?) versions of the compiler, this should work:

    go build -ldflags -H=windowsgui filename.go

    When I continued searching around I found a note that the official documentation should be updated soon, but in the meantime there are a lot of older-style example answers out there that error.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?