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

查看:29
本文介绍了如何从 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天全站免登陆