go下载依赖提示连接失败

1、现象

Go下载模块提示连接失败

dial tcp 142.251.42.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period
of time, or established connection failed because connected host has failed to respond.

 2、解决办法

①查看go env中的GOSUMDB变量

go env

 ②关闭GOSUMDB

go env -w GOSUMDB=off

 ③设置代理为https://goproxy.cn,direct

go env -w GOPROXY=https://goproxy.cn,direct

 

 ④再次下载

posted @ 2022-12-30 18:08  韩梦芫  阅读(1016)  评论(0编辑  收藏  举报