linux环境下golang安装第三方库的时候出错,求解决办法
使用如下方式安装beego的时候出错
go get github.com/astaxie/beego
错误信息:
go install unicode/utf8: open /opt/go/pkg/linux_amd64/unicode/utf8.a: permission denied
go install unicode: open /opt/go/pkg/linux_amd64/unicode.a: permission denied
go install math: open /opt/go/pkg/linux_amd64/math.a: permission denied
go install sort: open /opt/go/pkg/linux_amd64/sort.a: permission denied
go install hash: open /opt/go/pkg/linux_amd64/hash.a: permission denied
go install unicode/utf16: open /opt/go/pkg/linux_amd64/unicode/utf16.a: permission denied
go install crypto/subtle: open /opt/go/pkg/linux_amd64/crypto/subtle.a: permission denied
go install container/list: open /opt/go/pkg/linux_amd64/container/list.a: permission denied
go install internal/syscall: open /opt/go/pkg/linux_amd64/internal/syscall.a: permission denied
go install time: open /opt/go/pkg/linux_amd64/time.a: permission denied
然后我在命令前加了一个sudo,然后提示
go: cannot find GOROOT directory: /usr/local/go
我的golang环境配置如下:
GOARCH="amd64"
GOBIN="/opt/go/bin"
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/buchenglei/workspace/golang"
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"
该怎么解决呢?