我已经安装在一台Fedora 21笔记本电脑上,我安装了GOPATH和GOBIN,但出于某种原因,它不让我安装我的围棋程序。
pred@computer01 [20:03:02] ~
$ echo $GOPATH
/home/pred/Documents/GO
pred@computer01 [20:03:11] ~
$ echo $GOBIN
/home/pred/Documents/GO/bin
pred@computer01 [20:03:15] ~
$ cd $GOPATH
pred@computer01 [20:03:21] ~/Documents/GO
$ go install src/github.com/pred3/go_helloworld/helloworld/helloworld.go
go install: no install location for .go files listed on command line (GOBIN not set)
pred@computer01 [20:03:32] ~/Documents/GO
$ go env
GOARCH="amd64"
GOBIN="/home/pred/Documents/GO/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pred/Documents/GO"
GORACE=""
GOROOT="/usr/lib/golang"
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"我还能做些什么才能让这件事起作用?
-编辑--
如下所述,发出以下命令时也会出现错误。
pred@computer1 [21:22:51] ~/Documents/GO
$ go install src/github.com/pred3/go_helloworld/helloworld
can't load package: package src/github.com/predatorian3/go_helloworld/helloworld: cannot find package "src/github.com/pred3/go_helloworld/helloworld" in any of:
/usr/lib/golang/src/src/github.com/pred3/go_helloworld/helloworld (from $GOROOT)
/home/pred/Documents/GO/src/src/github.com/pred3/go_helloworld/helloworld (from $GOPATH)但是,在我试图安装的go文件开始时,我没有package main。一旦我把它改为package main,它就起作用了。我不知道为什么我不能使用不同的包名。
发布于 2015-08-05 02:58:42
去安装需要一个包作为参数(更详细的解释请参见包装清单说明 )。在你的情况下,可能应该是
go install github.com/pred3/go_helloworld/helloworld假设$GOPATH/src/github.com/pred3/go_helloworld/helloworld目录存在且$GOPATH/src/github.com/pred3/go_helloworld/helloworld/helloworld.go以package main开头
以下命令也会这样做:
cd $GOPATH/src/github.com/pred3/go_helloworld/helloworld
go intsallhttps://stackoverflow.com/questions/31822170
复制相似问题