go引入私有仓库

引入私有库

方式一:https方式

  • 禁用https检查

    git config --global http.sslVerify false
    
  • 设置git账户

    vim ~/.netrc

    machine git.code.oa.com
    login mocanxi
    password xxxx
    

    要是配置了如下之类信息,先删除。

    git config --global url."git@gitlab.com".insteadOf "https://gitlab.com"
    
  • 设置私有git地址

    go env -w GOPRIVATE="git.xxx.com"
    
  • 可以通过 HTTP 和其他不安全协议检索

    解决问题 x509 certificate has expired or is not yet valid

    go env -w GOINSECURE="git.xxx.com/mocanxi/echo"
    

方式二:ssh方式

  • 生成密钥

    cd ~/.ssh
    # 若存在 id_rsa 和 id_rsa.pub,可不执行重新生成
    
    ssh-keygen -t rsa -C "email"
    
    cat id_rsa.pub
    
  • 将公钥添加到git客户端,id_rsa.pub文件

  • 配置ssh配置使用ssh方式解析

    git config --global url."git@gitlab.com".insteadOf "https://gitlab.com"
    
  • 其他步骤与https相同

posted @ 2022-05-15 15:52  爱幻若影  阅读(427)  评论(0)    收藏  举报