如何从Golang创建可执行文件,该可执行文件在运行时不会打开控制台窗口? [英] How do I create an executable from Golang that doesn't open a console window when run?

查看:233
本文介绍了如何从Golang创建可执行文件,该可执行文件在运行时不会打开控制台窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个想要在后台隐形运行的应用程序(无控制台)。我该怎么做?

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

(这是Windows系统,在Windows 7 Pro 64位上测试)

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

推荐答案

在线找到的文档说我可以使用类似的东西进行编译,

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

go build -ldflags -Hwindowsgui filename.go

但这会产生错误: unknown flag -Hwindowsgui

使用较新的(1.1?)版本的编译器,这应该可以工作:

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.

这篇关于如何从Golang创建可执行文件,该可执行文件在运行时不会打开控制台窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆