go项目无法下载公司内部项目代码解决办法

问题,公司自建gitlab
有一个项目1,引用了项目2
项目1 go.mod有如下内容:
gitlab.xxxxxxx.net/platform/aaaaaa
但是在编译机上,无法下载

解决办法:
1,先在项目gitlab网站上添加sshkey。然后再把这个key添加到部署机上。
2,配置git clone http下载模式,不使用代理
go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOPRIVATE=gitlab.xxxxxxx.net
3,将git clone 的http下载方式改为 ssh下载
git config --global url.ssh://[email protected]:端口号/.insteadOf http://gitlab.westhpc.net/
4,/etc/ssh/ssh_config 或 $HOME/.ssh/config 文件添加

Host *
    StrictHostKeyChecking no
mkdir ~/.ssh
chmod 600 ~/.ssh

cat >> ~/.ssh/id_rsa <> ~/.ssh/id_rsa.pub <> /etc/ssh/ssh_config

go env -w GOPRIVATE=gitlab.westhpc.net
export GOPRIVATE=gitlab.westhpc.net
git config --global credential.helper store
git config --global url.ssh://[email protected]:端口号/.insteadOf http://gitlab.westhpc.net/

你可能感兴趣的:(docker)