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