I'm attempting to install a private repository as a golang module.
After reading the Microsoft blog post. I've attempted to do it locally.
I've updated the local .gitconfig with
[url "[email protected]:v3/<my org>/"]
insteadOf = https://dev.azure.com/<my org>/
Also exported to my environment:
export GOPRIVATE=dev.azure.com/<my org>/
The repository contains a go.mod
file with the following header:
module dev.azure.com/<my-org>/<project>/<repo>
go 1.18
When I attempt to install the module via:
go get -v dev.azure.com/<my-org>/<project>/<repo>.git@develop
It fails with:
go: dev.azure.com/<my-org>/<project>/<repo>[email protected]: parsing go.mod:
module declares its path as: dev.azure.com/<my-org>/<project>/<repo>
but was required as: dev.azure.com/<my-org>/<project>/<repo>.git
However, if I remove the .git
at the end it fails with:
203 Non-Authoritative Information
What's the appropriate way of importing private modules
Removing .git is a first step.
The 203 error is mentioned in golang/go
issue 41030, which redirects to issue 28236.
It includes:
If you are here due to authentication issues sync'ing with Azure DevOps repos with
go get
, e.g. on a build machine then you can setup a simple git credential helper in yourgitconfig
file: e.g:[credential "https://dev.azure.com"] helper = "/bin/sh /etc/azure-devops-helper.sh"
with
azure-devops-helper.sh
something like#!/bin/sh echo username=$USERNAME echo password=$AZURE_DEVOPS_TOKEN
where environment variables containing the username and PAT taken.
This proved more reliable for us than switching to SSH for azure repos.
And, for any 401 Gone
error:
Needed to tell explicitly in
GOPRIVATE
to not to check checksums ofdev.azure.com
.It seems it was really only that.