Using Azure DevOps for Private Go Modules


This took a few hours of work to iron out, so figured maybe I’d save someone time.

⚡ Just keep it simple and use SSH

⚡ Use even if using older to keep things simple.

Modules Support

Unlike GitHub, Azure DevOps has some quirks to deal with, specifically in the odd path handling.

My original goal was to set the default handling to be https support, with the SSH override in git config allowing me to use SSH.

This didn’t work.

  • HTTPS requires _git in the path.
  • SSH will not work with that, and also trims out the org name in the url when git config set based on instructions from Microsoft1.

There is a long-running issue with go get imports of Azure DevOps repositories due to the fact that the HTTPS URL contains a _git segment: 2

Compare the path.

HTTPSgo get<organization>/<project>/_git/<repo>
⚡ What I used with SSHgo get<project>/_git/<repo>
SSHgo get<organization>/<project>/<repo>.git

Git Config

Set this in your .profile, .bashrc, or $PROFILE


There are two approaches you can take.

One seems focused on allowing other public projects to be used. I’ve never had that need, so I’m ok with my references being resolved only to my own organization.

Support All Azure DevOps (Public)git config --global url."[email protected]:v3/<organization>/".insteadOf "<organization>"[url "[email protected]:v3"]<br/>

insteadOf =
⚡ What I Used for Private Orggit config --global url."[email protected]:v3/<organization>/".insteadOf "[url "[email protected]:v3/<organization>/"]

insteadOf =
Organization in Dependency Path
This changes the path for dependencies to not require the organization in the dependency path. Instead, the import path will look like this: import "<project>/repo.git/subdirectory"


If you don’t have restrictions on this, then you can do https with the following command to add the token in or use a more complex credential manager based process.

git config --global url."https://anythinggoeshere:$".insteadOf ""

Other References

  • SSH key usage in Azure Pipelines3.
  • Using with docker2

  1. Go get command support in Azure Repos Git ↩︎

  2. Private Go Modules on Azure DevOps ↩︎

  3. Install SSH Key task - Azure Pipelines | Microsoft Docs ↩︎


Likes  (1)
  • Carmen Holme