使用go的過(guò)程中耳鸯,會(huì)遇到有些包被墻了的情況
使用傳統(tǒng)的go寫(xiě)程序湿蛔,遇到被墻的包,通常是在官網(wǎng)下載對(duì)應(yīng)的包县爬,然后手動(dòng)創(chuàng)建對(duì)應(yīng)的目錄阳啥,把需要的包移進(jìn)去就行了。
而使用go module進(jìn)行包管理 的時(shí)候财喳,也會(huì)遇到這種情況察迟,解決方法如下。
手動(dòng)編輯go.mod文件,增加下面代碼
replace (
golang.org/x/net => github.com/golang/net latest
golang.org/x/tools => github.com/golang/tools latest
golang.org/x/crypto => github.com/golang/crypto latest
golang.org/x/sys => github.com/golang/sys latest
golang.org/x/text => github.com/golang/text latest
golang.org/x/sync => github.com/golang/sync latest
golang.org/x/exp => github.com/golang/exp latest
golang.org/x/lint => github.com/golang/lint latest
golang.org/x/oauth2 => github.com/golang/oauth2 latest
golang.org/x/time => github.com/golang/time latest
golang.org/x/image => github.com/golang/image latest
golang.org/x/mobile => github.com/golang/mobile latest
cloud.google.com/go => github.com/googleapis/google-cloud-go latest
google.golang.org/grpc => github.com/grpc/grpc-go latest
google.golang.org/appengine => github.com/golang/appengine latest
google.golang.org/genproto => github.com/googleapis/go-genproto latest
google.golang.org/api => github.com/googleapis/google-api-go-client latest
)
這樣就可以了耳高。缺少什么包扎瓶,就按照格式填就行。