go get国内源

前言#

Go语言学到 Gin 框架了, 其实每天学习是比较辛苦的事情, 坚持下去!

在使用 Go 过程中发现, 最无奈的是Go的一些模块下不下来, 即便挂了V, 油管2k不卡的那种, 依旧是 time out, 本文通过修改源为国内源的方法来规避此问题

正文#

推荐使用的两个, goproxy.cn 和 goproxy.io

连接分别是

https://goproxy.cn
https://goproxy.io

以下以cn举例,如想更换io步骤一样只是网址不一样

可直接跳转至 github 地址查看作者说明

https://github.com/goproxy/goproxy.cn/blob/master/README.zh-CN.md

首先开启 Go 的MODULE支持

在DOS中输入

SETX GO111MODULE on

Mac 为

export GO111MODULE=on

然后替换软件源

软件源推荐某大佬与七牛合作的源, 七牛作为CDN分发大厂, 还是比较可靠的 

https://github.com/goproxy/goproxy.cn

软件源为 

https://goproxy.cn

 

win直接在环境变量添加(CMD可能会遇到权限等问题),系统变量和用户变量都添加!

 

Mac 为

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

即可

(后面加direct是cn镜像没有找到会按照默认找)

GOLAND设置源#

GOLAND由于本身很完善所以会将项目的源覆盖,即使你已经在外面修改了源地址,当然,每次get前执行一遍设置国内源也是可以的,只是麻烦些

这里分享自带的setting修改(只对当前项目有用)

 

 

首先需要我们开启Go的MODULL支持

SETX GO111MODULE on

然后我们需要进行更改Go的GOPROXY值

go env -w GOPROXY=https://goproxy.cn,direct

SETX来设置一下Windows的环境变量

SETX GOPROXY=https://goproxy.cn,direct

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
如果你在使用 Debian 或 Ubuntu 等 Debian 系的 Linux 发行版,你可以通过以下步骤将默认的软件替换为国内的镜像。 1. 打开 `/etc/apt/sources.list` 文件,备份原文件: ``` sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak ``` 2. 编辑 `/etc/apt/sources.list` 文件,将所有的 `http://archive.ubuntu.com` 或 `http://deb.debian.org` 替换为以下其中一种镜像: - 中科大镜像(适用于 Debian/Ubuntu 等国内用户常用的 Linux 发行版): ``` deb https://mirrors.ustc.edu.cn/debian/ buster main contrib non-free deb https://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free deb https://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free deb https://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free # Uncomment the following line to add software from the proposed-updates # repository. # deb https://mirrors.ustc.edu.cn/debian/ buster-proposed-updates main contrib non-free ``` - 清华大学镜像(适用于 Debian/Ubuntu 等国内用户常用的 Linux 发行版): ``` deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free # Uncomment the following line to add software from the proposed-updates # repository. # deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-proposed-updates main contrib non-free ``` 或 ``` deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # Uncomment the following line to add software from Canonical's # 'partner' repository. # This software is not part of Ubuntu, but is offered by Canonical and the # respective vendors as a service to Ubuntu users. # deb https://partner-mirror.opensyscom.com/ubuntu bionic partner ``` 3. 保存文件并退出编辑器。 4. 更新软件: ``` sudo apt-get update ``` 现在,你的 Debian/Ubuntu 等 Debian 系 Linux 发行版系统将会使用国内的镜像进行软件包的下载和更新。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值