golang安装第三方包(简单版)

本文详细介绍了如何在Go语言环境中配置代理,包括Linux、Windows系统的具体操作步骤,以及推荐的国内代理服务。同时,提供了如何使用go get命令从GitHub获取依赖包的方法,适合在公司网络环境下进行Go语言开发的人员参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

做个标记,免得每次都忘记了。

首先需要正确配置gopath等

直接使用git

go get github.com/json-iterator/go

执行完就可以在goland里面直接引用了。(不太建议使用subline等文本编辑器,因为效率有点低)

代理

1.命令行方式

# 配置 GOPROXY 环境变量
export GOPROXY=https://goproxy.io,direct
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
export GOPRIVATE=git.mycompany.com,github.com/my/private

# 配置 GOPROXY 环境变量
$env:GOPROXY = "https://goproxy.io,direct"
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
$env:GOPRIVATE = "git.mycompany.com,github.com/my/private"
 

Linux

# 设置你的 bash 环境变量
echo "export GOPROXY=https://goproxy.io,direct" >> ~/.profile && source ~/.profile

# 如果你的终端是 zsh,使用以下命令
echo "export GOPROXY=https://goproxy.io,direct" >> ~/.zshrc && source ~/.zshrc


Windows

1. 右键 我的电脑 -> 属性 -> 高级系统设置 -> 环境变量
2. 在 “[你的用户名]的用户变量” 中点击 ”新建“ 按钮
3. 在 “变量名” 输入框并新增 “GOPROXY”
4. 在对应的 “变量值” 输入框中新增 “https://goproxy.io,direct”
5. 最后点击 “确定” 按钮保存设置
 

3、其他代理
可以看看这里:https://learnku.com/go/wikis/38122

国内代理:

七牛:Goproxy 中国 https://goproxy.cn
阿里: mirrors.aliyun.com/goproxy/
官方: < 全球 CDN 加速 https://goproxy.io/>
其他:jfrog 维护 https://gocenter.io
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值