How do I create an executable from Golang that doesn't open a console window when run?

后端 未结 3 1541
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 07:43

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

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

3条回答
  •  离开以前
    2020-12-02 08:08

    Using Go Version 1.4.2

     go build -ldflags "-H windowsgui" 
    

    From the Go docs:

    go build [-o output] [-i] [build flags] [packages]
    

    -ldflags 'flag list' arguments to pass on each 5l, 6l, or 8l linker invocation.

    • go build documentation
    • ldflags docs

提交回复
热议问题