go get golang.org/x/下载失败 | 运行报错exec: “gcc“: executable file not found in %PATH%

如下图我需要golang.org/x/net/websocket这个包
在这里插入图片描述

用GoLand下载包失败,报错

Fetching https://golang.org/x/net/websocket?go-get=1
https fetch failed: Get https://golang.org/x/net/websocket?go-get=1: dial tcp 216.239.37.1: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.
package golang.org/x/net/websocket/...: unrecognized import path "golang.org/x/net/websocket" (https fetch: Get https://golang.org/x/net/websocket?go-get=1: dial tcp 216.239.37.1: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.)

国内使用 go get 安装 golang 官方包会失败

解决办法

使用Git下载对应的包
golang 在 github 有镜像库
在Git窗口里依次执行下面的

mkdir -p $GOPATH/src/golang.org/x                 --比如我是 mkdir -p D:/Go/src/golang.org/x
cd $GOPATH/src/golang.org/x		                  --切换到 cd D:/Go/src/golang.org/x
git clone https://github.com/golang/net.git  

在这里插入图片描述


下载成功后GoLand自己就加载了
在这里插入图片描述


 

使用GoLand运行时报错
在这里插入图片描述

解决办法

安装gcc

下载安装tdm-gcc(windosw版本)官方下载地址:http://tdm-gcc.tdragon.net/download
官网下载超慢

提供百度网盘下载, 两个版本
tdm64-gcc-9.2.0    tdm64-gcc-5.1.0
链接:https://pan.baidu.com/s/1b7Qx1ZCH1eE-AKU3Ez7VSA
提取码:xxxx

在这里插入图片描述
点Create下载东西失败的话把Check那个框反勾选, 不检查服务器上的更新文件
除了安装路径自己选择, 其他一路默认next

最后Finish会弹出
在这里插入图片描述

配置环境变量
变量名: MW_MINGW64_LOC
变量值: D:\TDM-GCC-64 (安装路径)
在这里插入图片描述

cmd查看, 配置成功了
在这里插入图片描述

然后, 就运行成功了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值