go: writing stat cache: open per

2021-03-08  本文已影响0人  梨花菜

背景

原来是root用户执行的,后面改成lihuacai这个用户
执行go build时,提示

# lihuacai @ qa-cdh-001 in ~/code/go/src/GoBigDataTestTool on git:master x [11:14:23] C:2
$ go build
go: finding module for package github.com/go-sql-driver/mysql
go: finding module for package github.com/astaxie/beego/orm
go: finding module for package github.com/astaxie/beego
go: finding module for package github.com/tidwall/sjson
go: finding module for package github.com/tidwall/gjson
go: finding module for package gopkg.in/confluentinc/confluent-kafka-go.v1/kafka
go: writing stat cache: open /root/code/go/pkg/mod/cache/download/github.com/astaxie/beego/@v/v1.12.3.info1103410.tmp: permission denied
go: downloading github.com/astaxie/beego v1.12.3
go: writing stat cache: open /root/code/go/pkg/mod/cache/download/github.com/tidwall/gjson/@v/v1.6.8.info580695285.tmp: permission denied
go: downloading github.com/tidwall/gjson v1.6.8
go: writing stat cache: open /root/code/go/pkg/mod/cache/download/github.com/tidwall/sjson/@v/v1.1.5.info858958590.tmp: permission denied
go: downloading github.com/tidwall/sjson v1.1.5
go: writing stat cache: open /root/code/go/pkg/mod/cache/download/github.com/go-sql-driver/mysql/@v/v1.5.0.info69163632.tmp: permission denied
go: downloading github.com/go-sql-driver/mysql v1.5.0
controllers/kafka_template.go:12:2: open /root/code/go/pkg/mod/cache/download/github.com/astaxie/beego/@v/v1.12.3.lock: permission denied

解决

使用root用户执行[root@qa-cdh-001 ~]# chmod -R 775 /root/code/go/,修改文件权限
其中/root/code/goGOPATH
lihuacai属于root用户组,否则需要把775改成777
重新执行go build即可

上一篇下一篇

猜你喜欢

热点阅读