go环境下载github文件显示timeout解决方法

文章描述了在尝试用Go编译项目时遇到的网络超时错误,具体涉及github上的多个依赖包无法下载。为了解决这个问题,作者提供了配置GOPROXY代理的解决方案,通过设置`goenv-wGOPROXY=https://goproxy.cn`来使用国内镜像,从而成功编译项目。
摘要由CSDN通过智能技术生成

1、问题背景

go环境正常,需要去github拉取一个资源进行编译

go build -v -o naabu cmd/naabu/main.go

编译过程中报错如下:
pkg/runner/runner.go:19:2: github.com/miekg/dns@v1.1.53: Get "https://proxy.golang.org/github.com/miekg/dns/@v/v1.1.53.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/nmap.go:10:2: github.com/pkg/errors@v0.9.1: Get "https://proxy.golang.org/github.com/pkg/errors/@v/v0.9.1.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/runner.go:21:2: github.com/projectdiscovery/blackrock@v0.0.1: Get "https://proxy.golang.org/github.com/projectdiscovery/blackrock/@v/v0.0.1.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/runner.go:22:2: github.com/projectdiscovery/clistats@v0.0.15: Get "https://proxy.golang.org/github.com/projectdiscovery/clistats/@v/v0.0.15.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/runner.go:23:2: github.com/projectdiscovery/dnsx@v1.1.4: Get "https://proxy.golang.org/github.com/projectdiscovery/dnsx/@v/v1.1.4.zip": dial tcp 142.251.43.17:443: i/o timeout
cmd/naabu/main.go:4:2: github.com/projectdiscovery/fdmax@v0.0.4: Get "https://proxy.golang.org/github.com/projectdiscovery/fdmax/@v/v0.0.4.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/healthcheck.go:9:2: github.com/projectdiscovery/goflags@v0.1.8: Get "https://proxy.golang.org/github.com/projectdiscovery/goflags/@v/v0.1.8.zip": dial tcp 142.251.43.17:443: i/o timeout
cmd/naabu/main.go:5:2: github.com/projectdiscovery/gologger@v1.1.8: Get "https://proxy.golang.org/github.com/projectdiscovery/gologger/@v/v1.1.8.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/validate.go:17:2: github.com/projectdiscovery/gologger@v1.1.8: Get "https://proxy.golang.org/github.com/projectdiscovery/gologger/@v/v1.1.8.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/validate.go:18:2: github.com/projectdiscovery/gologger@v1.1.8: Get "https://proxy.golang.org/github.com/projectdiscovery/gologger/@v/v1.1.8.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/runner.go:25:2: github.com/projectdiscovery/mapcidr@v1.1.1: Get "https://proxy.golang.org/github.com/projectdiscovery/mapcidr/@v/v1.1.1.zip": dial tcp 142.251.43.17:443: i/o timeout
pkg/runner/targets.go:13:2: github.com/projectdiscovery/mapcidr@v1.1.1: Get "https://proxy.golang.org/github.com/projectdiscovery/mapcidr/@v/v1.1.1.zip": dial tcp 142.251.43.17:443: i/o timeout
 

 

2、解决方案

配置代理,命令如下:

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

然后再继续使用go命令去编译即可。

 go build -v -o naabu cmd/naabu/main.go

编译成功。

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值