各位大神,我在Redhat 6下面安装了Go,设置了GOPATH,GOBIN,GOROOT等。
#go set
export GOROOT=/opt/go
export GOBIN=$GOROOT/bin
export PATH=$GOBIN:$PATH
export GOARCH=amd64
export GOOS=linux
export GOPATH=/data/go
并且参考许式伟的Go语言编程写了sorter的go例子。我的编辑工具是liteide,go build都是成功的,但是Go install就报下述错误。
Current environment change id "system"
/opt/go/bin/go env [/opt/go]
GOARCH="amd64"
GOBIN="/opt/go/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/data/go"
GORACE=""
GOROOT="/opt/go"
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
Command exited with code 0.
/opt/go/bin/go build -v ./... [/data/go/sorter/src/algorithms/bubblesort]
_/data/go/sorter/src/algorithms/bubblesort
Success: process exited with code 0.
/opt/go/bin/go install -v ./... [/data/go/sorter/src/algorithms/bubblesort]
go install: no install location for directory /data/go/sorter/src/algorithms/bubblesort outside GOPATH
Error: process exited with code 1.
/opt/go/bin/go install -v ./... [/data/go/sorter/src/algorithms/qsort]
go install: no install location for directory /data/go/sorter/src/algorithms/qsort outside GOPATH
Error: process exited with code 1.
/opt/go/bin/go install -v ./... [/data/go/sorter/src]
sorter.go:5:2: cannot find package "algorithm/bubblesort" in any of:
/opt/go/src/algorithm/bubblesort (from $GOROOT)
/data/go/src/algorithm/bubblesort (from $GOPATH)
sorter.go:6:2: cannot find package "algorithm/qsort" in any of:
/opt/go/src/algorithm/qsort (from $GOROOT)
/data/go/src/algorithm/qsort (from $GOPATH)
Error: process exited with code 1.
/opt/go/bin/go install -v ./... [/data/go/sorter/src/algorithms/bubblesort]
go install: no install location for directory /data/go/sorter/src/algorithms/bubblesort outside GOPATH
Error: process exited with code 1.
请各位大神指教。
GOPATH 设置不对,应该为:
`export GOPATH=/data/go/sorter`
另外,别设置GOBIN,否则 go install 安装的东东会跑到 GOBIN 下面去
#1