Go modules, private repos and gopath

前端 未结 3 1272
谎友^
谎友^ 2020-12-16 13:17

We are converting our internal codebase from the dep dependency manager to go modules (vgo or built in with go1.11.2). Imagine we have code like th

3条回答
  •  独厮守ぢ
    2020-12-16 13:41

    I wrote up a solution for this on Medium: Go Modules with Private Git Repositories.

    The way we handle it is basically the same as the answer above from Alex Pliutau, and the blog goes into some more detail with examples for how to set up your git config with tokens from GitHub/GitLab/BitBucket.

    The relevant bit for GitLab:

    git config --global \
      url."https://oauth2:${personal_access_token}@privategitlab.com".insteadOf \
      "https://privategitlab.com"
    
    #or 
    
    git config --global \
      url."https://${user}:${personal_access_token}@privategitlab.com".insteadOf \
      "https://privategitlab.com"
    

    I hope it's helpful.

提交回复
热议问题