2015-11-02 141 views
-5

我想爲「發佈」製作一個Golang文件。如何爲「發佈」創建go文件?

這是我的命令:

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。

+0

你是什麼意思的「爲」發佈「'? – JimB

+0

在C++中有兩種模式:Release和Debug.example:在qt和C++中 程序是25.0 KB的「release」和調試:850 KB。 – ravandi

+0

這可能意味着在你的IDE中,但這不是一個C++的東西。如果您沒有專門針對「發行版」進行特別配置的任何內容,我不確定您期望爲「發行版」創建不同的版本。與DLL – JimB

回答

0

正如JimB,戴夫·切尼解釋說,和其他人:

  • 沒有 「釋放」 Golang
  • Golang可執行文件都很大,這是normal
  • 是的,你必須提供給如果強制鏈接共享庫,DLL文件
  • 是的,這些庫可能很大。
  • 沒有什麼錯,只是放手使用默認值
+0

我已經創建了發佈文件。 但是現在在另一臺電腦上有問題。 go文件現在不在另一臺計算機上執行。 – ravandi

+0

問題解決了。我使用了以下程序: procmon.exe – ravandi