科学安装 golang package

问题出现:

由于 The Great China Wall 的存在
我们下载包的时候,经常会遇到如下图所示的 timeout

科学安装 golang package_第1张图片
下载 package timeout

优雅的解决方法:

开启 goproxy 代理

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

小白步骤

  1. 打开一个终端
  2. 输入export GOPROXY=https://mirrors.aliyun.com/goproxy/
  3. 执行自己的下载方法 go get 等等

你会发现,快了很多。
尤其是每当遇到万恶的 golang.org/x/

更方便的写法

如果你是 Linux 或者 mac,将export GOPROXY=https://mirrors.aliyun.com/goproxy/ 这句,添加到 ~/.bashrc 文件末尾,省下每次输入的麻烦。

如果你和我一样使用的是zsh,就添加到 ~/.zshrc 中。

详细资料

阿里的镜像网站

科学安装 golang package_第2张图片
https://opsx.alibaba.com/mirror

你可能感兴趣的:(科学安装 golang package)