英文:
Go install doesn't create bin file
问题
问题类似于这里描述的问题,但是答案对我没有帮助。
我使用的是从源代码构建的Go 1.4版本。
我使用$ go install -x -a
命令来强制重新构建所有包(尽管我只对一个go文件进行了更改)。项目结构良好,包含一个名为main.go的文件,其中包含package main
和func 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
是你的工作空间,它应该始终包括src
、pkg
和bin
目录。
要为该命令获取一个特定的可执行文件:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论