Go install不会创建bin文件。

huangapple go评论90阅读模式
英文:

Go install doesn't create bin file

问题

问题类似于这里描述的问题,但是答案对我没有帮助。

我使用的是从源代码构建的Go 1.4版本。
我使用$ go install -x -a命令来强制重新构建所有包(尽管我只对一个go文件进行了更改)。项目结构良好,包含一个名为main.go的文件,其中包含package mainfunc main()
我已经尝试了很多方法,但对构建过程有了更好的理解...

$ go env
GOARCH="386"
GOBIN=""
GOCHAR="8"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jdevoo/Downloads/go"
GORACE=""
GOROOT="/home/jdevoo/go"
GOTOOLDIR="/home/jdevoo/go/pkg/tool/linux_386"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

有什么想法吗?

英文:

Issue is similar to the one described here but the answer did not help me.

I use Go 1.4 built from source.
I have issued $ go install -x -a to force the rebuild of all packages (although I only made a change to a single go file). The project is well structured and contains a command in a file named main.go with package main and func main()
I am running out of ideas but gained a better understanding of the build process...

$ go env
GOARCH="386"
GOBIN=""
GOCHAR="8"
GOEXE=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jdevoo/Downloads/go"
GORACE=""
GOROOT="/home/jdevoo/go"
GOTOOLDIR="/home/jdevoo/go/pkg/tool/linux_386"
CC="gcc"
GOGCCFLAGS="-fPIC -m32 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Any ideas?

答案1

得分: 0

这取决于你的main.go文件的确切位置。

它应该位于$GOPATH/src/yourProject/main.go,这样go install命令才能生成$GOPATH/bin/yourProject。这就是"Your first program"中所描述的。

$GOPATH你的工作空间,它应该始终包括srcpkgbin目录。

要为该命令获取一个特定的可执行文件:

cd $GOPATH/src/github.com/eris-ltd/decerver/cmd/decerver/
go get
# 或者
go install

请注意,-x选项只会“打印命令”,-a选项会强制重新构建。

英文:

It really depends on where exactly is your main.go.

It should be in $GOPATH/src/yourProject/main.go, for a go install to generate a $GOPATH/bin/yourProject.
That is what "Your first program" describes.

$GOPATH is your workspace, and should always include src, pkg and bin.

To get a binary specifically for that command:

cd $GOPATH/src/github.com/eris-ltd/decerver/cmd/decerver/
go get
# or
go install

Note the -x option is supposed to "print the command" only.
-a would force rebuilding.

huangapple
  • 本文由 发表于 2015年1月11日 22:56:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/27888406.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定