I want to require a specific module of a private azure repository. The module is in a subdirectory of said repository. This results in a required module that contains an undesired [...].git/[...]
in the module path.
Following the Microsoft documentation for HTTPS I am able to get the complete repository but encounter the following issue when requiring a subdirectory.
.gitconfig
[url "https://user.name:token@dev.azure.com/company/project/_git/repo"]
insteadOf = https://dev.azure.com/company/project/_git/repo
GOPRIVATE
"GOPRIVATE": "dev.azure.com"
Example 1
go get dev.azure.com/company/project/_git/repo.git/go
go: module dev.azure.com/company/project/_git/repo.git@upgrade found (v0.0.0), but does not contain package dev.azure.com/company/project/_git/repo.git/go
Expectation
require dev.azure.com/company/project/_git/repo/go
Example 2
go get dev.azure.com/company/project/_git/repo.git/go/pkg/mypkg@feature/#99999/mybranch
go: dev.azure.com/company/project/_git/repo.git/go/pkg/mypkg@feature/#98667/mybranch (v0.0.0) requires dev.azure.com/company/project/_git/repo.git/go/pkg/mypkg@v0.0.0: parsing go.mod:
module declares its path as: dev.azure.com/company/project/_git/repo/go/pkg/mypkg
but was required as: dev.azure.com/company/project/_git/repo.git/go/pkg/mypkg
Expectation
require dev.azure.com/company/project/_git/repo/go/pkg/mypkg
In the repository of your Go modules, open the subfolder "go
" and ensure a "go.mod
" file is existing.
module dev.azure.com/<organization-name>/<project-name>/_git/<repository-name>.git/go
go 1.14
See below example as reference:
The Go module.
go.mod
file
module dev.azure.com/BriRanAdoOrg/ProjDemo/_git/myGoModule.git/MathCalc
go 1.14
Operators.go
file
package Operators
func Addition(num1 float64, num2 float64) float64 {
return num1 + num2
}
func Subtraction(num1 float64, num2 float64) float64 {
return num1 - num2
}
func Multiplication(num1 float64, num2 float64) float64 {
return num1 * num2
}
func Division(num1 float64, num2 float64) float64 {
return num1 / num2
}
The Go app which needs to use the Go module.
The go.mod
file
module myGoApp
go 1.14
The .gitconfig
file
[url "https://<username>:<pat>@dev.azure.com/BriRanAdoOrg/ProjDemo/_git/myGoModule"]
insteadOf = https://dev.azure.com/BriRanAdoOrg/ProjDemo/_git/myGoModule
The main.go
file
package main
import (
"fmt"
"dev.azure.com/BriRanAdoOrg/ProjDemo/_git/myGoModule.git/MathCalc"
)
func main() {
var num1 = 3.6
var num2 = 1.2
fmt.Printf("%v + %v = %.2f\n", num1, num2, Operators.Addition(num1, num2))
fmt.Printf("%v - %v = %.2f\n", num1, num2, Operators.Subtraction(num1, num2))
fmt.Printf("%v x %v = %.2f\n", num1, num2, Operators.Multiplication(num1, num2))
fmt.Printf("%v ÷ %v = %.2f\n", num1, num2, Operators.Division(num1, num2))
}
The result.
go get dev.azure.com/BriRanAdoOrg/ProjDemo/_git/myGoModule.git/MathCalc
" command can successfully download and parse the module.go run main.go
" command can successfully run the app.