Go modules, private repos and gopath

前端 未结 3 1270
谎友^
谎友^ 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 use a workaround with GITHUB_TOKEN to solve this.

    1. Generate GITHUB_TOKEN here https://github.com/settings/tokens
    2. export GITHUB_TOKEN=xxx
    3. git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/mycompany".insteadOf "https://github.com/mycompany"
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-16 13:47

    I use ls-remote git command to help resolve private repo tags and go get after it.

    $ go env GO111MODULE=on
    $ go env GOPRIVATE=yourprivaterepo.com
    $ git ls-remote -q https://yourprivaterepo.com/yourproject.git
    $ go get
    
    0 讨论(0)
提交回复
热议问题