Private Go Modules on Azure DevOps

Using a Personal Access Token

git config --global url."https://anythinggoeshere:$".insteadOf ""
go get -v${ORG}/${PROJECT}/_git/${REPO}.git
FROM golang:1.12-alpine3.10 AS builderRUN apk add --no-cache git bashWORKDIR /codeARG devops_token
RUN git config --global url."https://anythinggoeshere:$".insteadOf ""
COPY go.mod go.sum ./RUN go mod downloadCOPY . .RUN go build -o main .RUN rm $HOME/.gitconfig
docker build \
-t $IMAGE:$TAG \
--build-arg devops_token=$DEVOPS_TOKEN \
DEVOPS_TOKEN_SECRET_NAME ?= "devops-repo-pat"
@token=`az keyvault secret show --name $(DEVOPS_TOKEN_SECRET_NAME) --vault-name $(VAULT_NAME) --query value -o tsv`; \
[ -z "$$token" ] && echo "failed to fetch token..." && exit 1; \
git config --global --unset $(git config --global --get-regexp "") &>/dev/null || "true" ; \
git config --global url."https://anything:$$".insteadOf ""
# has the SSH equivalent
git config --global url."".insteadOf
go mod init
go get -v -u
package mainimport (
hello ""
func main() {



Software Engineer @ Securitas Intelligent Products

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store