美文网首页golang
Go module使用中,被墙解决方法!

Go module使用中,被墙解决方法!

作者: rushui | 来源:发表于2020-04-30 14:05 被阅读0次

    使用go的过程中,会遇到有些包被墙了的情况

    使用传统的go写程序,遇到被墙的包,通常是在官网下载对应的包,然后手动创建对应的目录,把需要的包移进去就行了。
    而使用go module进行包管理 的时候,也会遇到这种情况,解决方法如下。

    手动编辑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
    )
    

    这样就可以了。缺少什么包,就按照格式填就行。

    相关文章

      网友评论

        本文标题:Go module使用中,被墙解决方法!

        本文链接:https://www.haomeiwen.com/subject/tjmzwhtx.html