天天看點

go mod的使用

使用go mod,注意你所使用的go版本應為11以上。

go mod的思想類似于maven:擁抱本地庫,使用go mod後,你會發現go modules 下載下傳的包在 GOPATH/pkg/mod。具體使用可檢視下面位址。

官網

https://github.com/golang/go/wiki/Modules  

不同管理工具對比

https://github.com/golang/go/wiki/PackageManagementTools

go mod的使用

https://studygolang.com/articles/19010

https://ieevee.com/tech/2018/08/28/go-modules.html?utm_source=tuicool&utm_medium=referral

有些包無法擷取,比如:golang.org,google.golang.org,cloud.google.com等,可采用GOPROXY,需要go版本為13以上

https://goproxy.io/

報錯并解決

1.module declares its path as: oauth2,but was required as: github.com/llaoj/oauth2

場景:clone 代碼(https://github.com/llaoj/oauth2.git)到本地,運作後報錯

解決:删除go.mod,go.sum,重新初始化go mod init github.com/llaoj/oauth2,注意觀察go.mod的module