go mod 使用私有gitlab群组的解决办法


由于go对私有gitlab的仓库支持不好,得使用下面这些步骤

  • 设置git使用 ssh协议 git config --global url."git@gitlab.com:".insteadOf "https://gitlab.com/"

  • 添加ssh key 到gitlab

    1. ssh-keygen 会生成 id_rsa.pub
    2. 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也是如此


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM