Trying to get Go modules to play ball with private repos?

go modules are wonderful. All go code should use them.

It can still be a bit tricky getting private repos to work with go mod. Maybe these tips help… ¯\_(ツ)_/¯

  • Set up SSH keys with your version control vendor

  • Add the following to your ~/.gitconfig:

      [url "ssh://[email protected]/"]
          insteadOf = https://github.com/
      [url "ssh://[email protected]/"]
        insteadOf = https://gitlab.com/
      [url "ssh://[email protected]/"]
        insteadOf = https://bitbucket.org/
    
  • Add the offending repo as a private repo:

      go env -w GOPRIVATE=gitlab.com/you/your-project,github.com/someone/their-project
    
comments powered by Disqus