【问题标题】:How to create a go file for “release”?如何为“发布”创建一个 go 文件?
【发布时间】:2016-02-02 17:32:18
【问题描述】:

我想为“发布”制作一个 Golang 文件。

这是我的命令:

go build -o testi.exe -ldflags "-H windowsgui"

正确的方法是什么?我的代码:

package main
import (
    "fmt"
    "os"
    //"github.com/chai2010/qml"
    "github.com/go-qml/qml"
)
func main() {
    if err := qml.Run(run); err != nil {
        fmt.Fprintf(os.Stderr, "error: %v\n", err)
        os.Exit(1)
    }
}
func run() error {
    engine := qml.NewEngine()
    engine.On("quit", func() { os.Exit(0) })

    component, err := engine.LoadString("hello.qml", qmlHello)
    if err != nil {
        return err
    }
    window := component.CreateWindow(nil)
    window.Show()
    window.Wait()
    return nil
}

const qmlHello = `
import QtQuick 2.2
import QtQuick.Controls 1.1
Rectangle {
    id: page
    width: 320; height: 240
    color: "lightgray"
    Text {
        id: helloText
        text: "Hello world!"
        y: 30
        anchors.horizontalCenter: page.horizontalCenter
        font.pointSize: 24; font.bold: true
    }
}
`

我安装了:go1.5.windows-386。

【问题讨论】:

  • 你所说的“为了“发布”是什么意思?
  • 在 C++ 中有两种模式:Release 和 Debug.example:在 qt 和 c++ 中,“发布”的程序为 25.0 KB 而调试:850 KB。
  • 这可能意味着您的 IDE 中的某些东西,但这不是 C++ 的东西。如果您没有为非发布版本专门配置任何内容,我不确定您希望 Go 为发布版本构建什么不同。
  • 带 dll 的总程序大小:743mb 所需的一切:libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll Qt5Cored.dll Qt5Guid.dll Qt5Networkd.dll Qt5Qmld.dll Qt5Quickd.dll Qt5Widgetsd .dll
  • forum.golangbridge.org/t/create-go-file-for-release/1415查看关于这个问题的其他讨论

标签: go qml release


【解决方案1】:

正如 JimB、Dave Cheney 和其他人所解释的:

  • Golang 没有“RELEASE”
  • Golang 可执行文件很大,即normal
  • 是的,如果你强制链接共享库,你必须提供给 DLL 文件
  • 是的,这些库可能很大。
  • 没有错,放手使用默认值

【讨论】:

  • 我已经创建了发布文件。但它现在在另一台计算机上出现问题。 go 文件,现在不在另一台计算机上执行。
  • 问题解决了。我使用了以下程序:procmon.exe
猜你喜欢
  • 2017-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-05
  • 1970-01-01
  • 2015-06-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多