go mod download 下载失败

build command-line-arguments: cannot load github.com/shopspring/decimal: module github.com/shopspring/decimal: Get https://goproxy.io/github.com/shopspring/decimal/@v/list: dial tcp 119.28.201.50: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.

导入第三方包 如 "github.com/shopspring/decimal" 失败

解决方法 打开cmd,然后输入:

1、查看 go 版本

go version

2、如果版本为 1.13 及以上

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct

  低于 1.13 版本

$env:GO111MODULE="on"
$env:GOPROXY="https://goproxy.io"

修改了下载的代理地址


 分析记录

然后继续执行失败操作 即可成功

go mod download
go run main.go

 

此时在你的 gopath 路径下的 pkg/mod 包下存有你刚刚导入的包

go.mod 文件发生改变,并且多出了一个 go.sum

原文地址:https://www.cnblogs.com/smuzoey/p/13915368.html