由於go對私有gitlab的倉庫支持不好,得使用下面這些步驟
-
設置git使用 ssh協議
git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"
-
添加ssh key 到gitlab
- ssh-keygen 會生成 id_rsa.pub
- cat ~/.ssh/id_rsa.pub 粘貼到gitlab 右上角頭像 Setting -> SSH keys,或者打開鏈接https://gitlab.com/profile/keys
-
修改 go.mod 添加
replace gitlab.com/YourGroup/SubGroup/Project => gitlab.com/YourGroup/SubGroup/Project.git master
-
設置noproxy域名
go env -w GONOPROXY=\*\*.gitlab.com\*\*
-
設置private域名
go env -w GOPRIVATE=\*\*.gitlab.com\*\*
自己搭建的gitlab也是如此