我try 了各种方法来创建一个只显示MessageBox或独立GUI窗口的Go程序.

package main
func main() {
...
}

为了避免这种情况,我try 了example,它创建了一个WinMain

func WinMain(wproc uintptr) {
    hInstance := GetModuleHandle(nil)
    ...
}

但是效果是一样的:空的控制台窗口and和GUI窗口: enter image description here

推荐答案

-ldflags -H=windowsgui添加到go build/install命令行.您将看到控制台窗口不存在:

enter image description here

Go相关问答推荐

有没有更简单的方法在Go中编写这个逻辑?

验证访问令牌(密钥罩)

Golang XML密钥名称冲突

在GO中使用泛型类型 struct 实现接口方法

如何在v2 Go SDK中使用KeyConditionExpression查询AWS DynamoDb?

将DATE类型的SQL字段扫描到GO struct 字段

从MySQL/GO表获取行数据

如何在链接中写入链接

Go 中如何判断 struct 体是否包含另一个 struct 体?

当我使用 CircleCI 构建 Go Image 时,我得到runtime/cgo: pthread_create failed: Operation not allowed

「GORM错误」不支持的数据类型:&[],不正确的模式

当填充通道的函数调用未嵌入 goroutine 时,为什么我会遇到死锁?

如何使用管理员权限启动 powershell 进程并重定向标准输入 (os.exec)

上传图片失败,出现错误dial tcp: lookup api.cloudinary.com: no such host

AddE 上的 Apache Tinkerpop gremlin-go 驱动程序 Next() 返回E0903:没有剩余结果

Golang:如何判断通过缓冲通道进行通信时生产者或消费者是否较慢?

Wire google Inject with multi return from provider 函数

如何使用特定的 Go 版本运行 govulncheck?

golang 如何从字符串中查找表情符号?

有没有办法停止long blocking 函数?