Gin框架执行:go get -u github.com/gin-gonic/gin 报错
-
错误信息:
//无法导入gin包:
go: module github.com/gin-gonic/gin: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/list": dial tcp 142.251.43.17:443: conne
ctex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connectio
n failed because connected host has failed to respond.
-
错误原因:
-
本地访问Gin框架的主机(142.251.43.17:443)延迟导致;
-
需要设置go get的代理;
-
-
解决方案:
-
1,打开终端,查看go语言环境:go env
-
2,查看是否有代理配置,如果没有,则需要配置代理;
-
推荐代理:https://goproxy.cn/
-
操作命令:
#命令1:
go env -w GO111MODULE=on
#命令2:
go env -w GOPROXY=https://goproxy.cn,direct
#如果执行命令1报错:warning: go env -w GO111MODULE=... does not override conflicting OS environment variable
#报错原因:说明当前配置已经在系统环境变量中配置了,使用go env -w 方式无效,可以直接通过修改环境变量的配置中的参数来修改;
#解决方案:
1:windows+R
2:输入cmd回车,进入cmd.exe
3,输入:go env,查看 GOPROXY
4,输入命令修改GOPROXY:go env -w GOPROXY=https://goproxy.cn,direct
5,再次查看:go env,确认已修改需要的代理即可;
-
-
3,再次输入命令:go get github.com/gin-gonic/gin
-
即可正常下载gin;
-
-
标签:github,报错,env,go,gin,com,gonic From: https://www.cnblogs.com/gzs1024/p/16883792.html