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 官方包会失败

解决办法

golang 在 github 有镜像库
使用Git下载对应的包
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运行时报错
在这里插入图片描述

解决办法

安装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查看, 配置成功了
在这里插入图片描述

然后, 就运行成功了

猜你喜欢

转载自blog.csdn.net/qq_40803085/article/details/107656521