在model中创建core.go时,需要使用gorm.io/driver/mysql,引入了gorm.io/driver/mysql,使用go mod tidy 更新,出现如下错误:

F:\www\go-data\src\go_code\gin\gindemo>go mod tidy
go: finding module for package gorm.io/driver/mysql
go: downloading gorm.io/driver/mysql v1.4.6
gindemo/models imports
        gorm.io/driver/mysql: gorm.io/driver/mysql@v1.4.6: verifying module: gorm.io/driver/mysql@v1.4.6: checking tree#15366953 agai
nst tree#15495139: reading https://goproxy.io/sumdb/sum.golang.org/tile/8/1/234: 404 Not Found
        server response: not found
nst tree#15495139: reading https://goproxy.io/sumdb/sum.golang.or
g/tile/8/1/234: 404 Not Found
        server response: not found

该原因是国内被墙了,解决方案:

终端依次输入: 

go env -w GOSUMDB=off
go env -w GOPROXY=https://goproxy.cn

重新go mod tidy即可:

F:\www\go-data\src\go_code\gin\gindemo>go env -w GOSUMDB=off

F:\www\go-data\src\go_code\gin\gindemo>go env -w GOPROXY=https://goproxy.cn
warning: go env -w GOPROXY=... does not override conflicting OS environment variable

F:\www\go-data\src\go_code\gin\gindemo>go mod tidy
go: finding module for package gorm.io/driver/mysql
go: downloading gorm.io/driver/mysql v1.4.6
go: found gorm.io/driver/mysql in gorm.io/driver/mysql v1.4.6

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐