配置private git仓库 使用ssh协议拉取go.mod包

配置private git仓库 使用ssh协议拉取go.mod包

默认私有仓库的依赖(例如公司内部gitlab仓库)是无法用go get(go get 默认走http方法)拉取到的,
假设私有仓库的hostname为:http://git.mycompany.net
需要做如下配置:

运行命令

git config --global url."git@git.mycompany.net:".insteadOf "https://git.mycompany.net/"

对于mac,运行命令

echo "GOPRIVATE=git.mycompany.net" >> ~/.bash_profile

对于ubuntu,运行命令

echo "GOPRIVATE=git.mycompany.net" >> ~/.bash_rc

说明:

配置git,访问http://git.mycompany.net时使用ssh协议(而不是https),从而获得ssh私钥提供的身份信息。
否则会因为缺失身份信息而无法拉取依赖。
配置GOPRIVATE环境变量,标记域名http://git.mycompany.net的包属于私有仓库,不做module的sum校验,否则拉取私有库会失败。

set GOPRIVATE=http://git.mycompany.net/*
set GONOPROXY=http://git.mycompany.net/*
set GONOSUMDB=http://git.mycompany.net/*
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值