转载请注明出处:

  在编译go项目时,遇到依赖下载超时,异常输出如下:

CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -ldflags '-extldflags "-static"' -o ../../bin/gobmp ./gobmp.go
go: google.golang.org/protobuf@v1.30.0: unrecognized import path "google.golang.org/protobuf": https fetch: Get "https://google.golang.org/protobuf?go-get=1": dial tcp 142.251.211.241:443: i/o timeout
go: google.golang.org/protobuf@v1.30.0: unrecognized import path "google.golang.org/protobuf": https fetch: Get "https://google.golang.org/protobuf?go-get=1": dial tcp 142.251.211.241:443: i/o timeout

  Go 在尝试访问模块 google.golang.org/protobuf 的时候出现了超时。这个问题通常可以归因于以下几个因素:网络连接问题、DNS 解析问题、被防火墙阻挡、或者其他网络配置相关的问题。

问题定位

1.网络问题

  确保可以访问 google.golang.org。尝试使用网络工具检查连接:

ping google.golang.org  

  或者

curl -v https://google.golang.org/protobuf  

  如果这些命令返回错误,那么网络连接本身可能存在问题。

2.DNS 问题

  如果你的 DNS 服务器有问题,可以尝试更换 DNS 服务器。例如,更换为 Google 的 DNS:

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf  

  然后再尝试 build。

3.防火墙设置

  确保没有防火墙或网络策略阻止访问这些地址。

代理连接

  如果以上方法无法解决问题,下面是一些可以使用的 Go 代理(这些代理可以帮助你在访问 Go 模块时使用不同的网络路径):

Go 中国代理(如果你在中国大陆):

export GOPROXY=https://goproxy.cn  

Goproxy.io(公共代理):

export GOPROXY=https://goproxy.io,direct  

Golang Proxy(Google 官方代理):

export GOPROXY=https://proxy.golang.org,direct  

其他公共代理

可以这样设置:

export GOPROXY=https://mirrors.aliyun.com/goproxy,direct  

禁用 checksum 数据库(如果你无法访问官方代理):

export GOSUMDB=off  

手动获取模块

go get google.golang.org/protobuf@v1.30.0  

go 编译超时解决的更多相关文章

  1. Linux Vsftpd 连接超时解决方法

    Linux Vsftpd 连接超时解决方法 2013-11-13 10:58:34|  分类: 默认分类|举报|字号 订阅     解决方法(http://www.lingdus.com/thread ...

  2. Keil4 每次选build 编译(F7)都全部编译的解决办法

    Keil4 每次选build 编译(F7)都全部编译的解决办法 http://blog.csdn.net/wchengshen/article/details/50440079 Keil4 每次选bu ...

  3. Eclipse启动Tomcat时,45秒超时解决方式

    Eclipse启动Tomcat时,45秒超时解决方式 在Eclipse中启动Tomcat服务器时,经常由于系统初始化项目多,导致出现45秒超时的Tomcat服务器启动错误.  一般通过找到XML配置文 ...

  4. 在vs2010中编译log4cxx-0.10.0详细方法(从下载、编译、解决错误详细介绍)

    在vs2010中编译log4cxx-0.10.0详细方法(从下载.编译.解决错误详细介绍) http://blog.sina.com.cn/s/blog_a459dcf501013tbn.html

  5. xxx was built without full bitcode" 编译错误解决

    xxx was built without full bitcode" 编译错误解决 iOS 打包上线 All object files and libraries for bitcode ...

  6. 基于ORA-12170 TNS 连接超时解决办法详解

    转自原文 基于ORA-12170 TNS 连接超时解决办法详解 1.开始----程序-----Oracle------配置和移植工具-----Net Manager----本地----服务命名---o ...

  7. .net core 下使用StackExchange的Redis库访问超时解决

    原文:.net core 下使用StackExchange的Redis库访问超时解决 目录 问题:并发稍微多的情况下Redis偶尔返回超时 给出了参考网址? 结论 小备注 引用链接 问题:并发稍微多的 ...

  8. Sublime Text通过插件编译Sass为CSS及中文编译异常解决

    虽然PostCSS才是未来,但是Sass成熟稳定,拥有一大波忠实的使用者,及开源项目,且最近Bootstrap 4 alpha也从Less转到Sass了.所以了解Sass还是非常有必要的. 基于快速开 ...

  9. [转]Eclipse启动Tomcat时45秒超时解决方法

    原文地址:http://it.oyksoft.com/post/6577/ Eclipse启动Tomcat时,默认配置的启动超时时长为45秒.假若项目启动超过45秒将会报错.两种解决方法:1.改XML ...

  10. Linux Vsftpd 连接超时解决方法(被动模式)

    http://blog.csdn.net/qq_15766181/article/details/46554643 使用 FileZilla FTP Client 连接 Vsftpd FTP,在没有配 ...

随机推荐

  1. Nodejs+npm详细安装

    Nodejs详细安装步骤1.去官网下载nodejs,下载地址:https://nodejs.org/en/download/ 根据自己要求下载,我这里下载的是windows installer的. 2 ...

  2. POJ-2385 Apple Catching(基础dp)

    It is a little known fact that cows love apples. Farmer John has two apple trees (which are convenie ...

  3. java_day1_认识计算机,java环境,Java关键字、标识符、注释

    一.认识计算机 1.组成: 硬件:cpu,内存,显卡,... 软件: 系统软件:WPS, wegame, steam, IDEA,..... 应用软件:WPS, wegame, steam, IDEA ...

  4. SpringBoot创建微服务项目

    下载安装并配置git 为自己的git设置名字 git config --global user.name "XXX" 配置自己注册码云的邮箱 git config --global ...

  5. 数据库周刊59丨GaussDB(for openGauss)开放商用;人大金仓保障冬奥会演练顺利完成;MDL锁导致的MySQL问题分析;PG日志使用手册;达梦表空间查询;数据库笔试题面试题集……

    热门资讯 1.openGauss 上线华为云正式商用 - GaussDB(for openGauss) [摘要]近日,GaussDB(for openGauss)已于华为云官网全面开放商用.该产品是华 ...

  6. Ewald求和在分子静电势能计算中的应用

    技术背景 分子动力学模拟中,计算周期性边界条件的静电势常被视作计算的瓶颈之一.形式上是比较容易的,例如不考虑周期性边界条件的话,静电势能就是: \[E=\frac{1}{4\pi\epsilon_0} ...

  7. modbus基础

    Modbus是一种单主站的主从通信模式,Modbus只能有一个主站,允许多个从站(0-247):从站之间不能交流:主站发送数据,从站应答: 一主多从 : 1. 地址码,表,功能码 地址码一般是Modb ...

  8. vue项目中的package.json的private选项的作用

    { "name": "项目名称", "description": "描述", "version": ...

  9. 将Vscode添加右键打开文件夹功能

    1. wan + r 输入 regedit 打开注册表 注册表编辑 2. 找到 HKEY_CLASSES_ROOT\*\shell分支 3. 在shell下新建"VisualCode&quo ...

  10. Kubernetes上安装nacos

    k8s配置 --- apiVersion: apps/v1 kind: Deployment metadata: name: nacos namespace: com spec: selector: ...