1.错误描述
使用如下方式安装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
2.解决办法
go install unicode/utf8: open /opt/go/pkg/linux_amd64/unicode/utf8.a: permission denied
出现这样的错误原因是,当初我是直接将golang的压缩包拷到了/opt目录下,所有的源代码都未经编译,应该先切换到/opt/go/src目录下,执行sudo ./make.bash脚本编译,完成后在使用如下命令安装beego就不会出错了:
go get github.com/astaxie/beego
这样的话,在执行如下命令安装bee工具的时候会提示权限不够:
go get github.com/beego/bee
go install github.com/beego/bee: open /opt/go/bin/bee: permission denied
对此我的解决办法是先切换到/opt目录,执行如下命令,修改go文件夹的权限:
sudo chmod -R 777 go/
这样就能正常安装bee工具了。