Description
What version of Go are you using (go version
)?
$ go version go version go1.15.2 linux/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go envGO111MODULE=""
GOARCH="amd64"
GOBIN="/home/divinerapier/code/gopath/bin"
GOCACHE="/home/divinerapier/.cache/go-build"
GOENV="/home/divinerapier/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/divinerapier/code/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/divinerapier/code/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/divinerapier/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/divinerapier/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build936972071=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I have a private repo: https://my.gitlab.com/group0/group1/group2/repo
. And group0
, group1
and group2
are all group names.
And then I want to use it as a dependency in another repo in go.mod file.
But go mod tidy -v
thinks that the repo is my.gitlab.com/group0/group1
$ go mod tidy -v
get "my.gitlab.com/group0/group1/group2/repo": found meta tag get.metaImport{Prefix:"my.gitlab.com/group0/group1", VCS:"git", RepoRoot:"https://my.gitlab.com/group0/group1.git"} at //my.gitlab.com/group0/group1/group2/repo?go-get=1
What did you expect to see?
I want the go mod
works.
What did you see instead?
get "my.gitlab.com/group0/group1/group2/repo": found meta tag get.metaImport{Prefix:"my.gitlab.com/group0/group1", VCS:"git", RepoRoot:"https://my.gitlab.com/group0/group1.git"} at //my.gitlab.com/group0/group1/group2/repo?go-get=1
get "my.gitlab.com/group0/group1/group2/repo": verifying non-authoritative meta tag
go: my.gitlab.com/group0/group1/group2/repo@v0.0.3: reading my.gitlab.com/group0/group1/group2/repo/group2/repo/go.mod at revision group2/repo/v0.0.3: unknown revision group2/repo/v0.0.3
I add some logs in function repoRootForImportDynamic
in file src/cmd/go/internal/get/vcs.go
func repoRootForImportDynamic(importPath string, mod ModuleMode, security web.SecurityMode) (*RepoRoot, error) {
url, err := urlForImportPath(importPath)
if err != nil {
return nil, err
}
fmt.Printf("importPath: %s, url: %v, err: %v\n", importPath, url, err)
resp, err := web.Get(security, url)
if err != nil {
msg := "https fetch: %v"
if security == web.Insecure {
msg = "http/" + msg
}
return nil, fmt.Errorf(msg, err)
}
body := resp.Body
defer body.Close()
bodyData, err := ioutil.ReadAll(body)
imports, err := parseMetaGoImports(bufio.NewReader(bytes.NewBuffer(bodyData)), mod)
fmt.Printf("imports: %v, err: %v, \nbody: %s, \nmod: %v\n", imports, err, bodyData, mod)
...
// Find the matched meta import.
mmi, err := matchGoImport(imports, importPath)
fmt.Printf("imports: %v, importPath: %v, mmi: %v, err: %v\n", imports, importPath, mmi, err)
...
}
logs are
importPath: my.gitlab.com/group0/group1/group2/repo, url: //my.gitlab.com/group0/group1/group2/repo?go-get=1, err: <nil>
imports: [{my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}], err: <nil>,
body: <html><head><meta name="go-import" content="my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git" /></head></html>,
mod: 1
imports: [{my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}], importPath: my.gitlab.com/group0/group1/group2/repo, mmi: {my.gitlab.com/group0/group1 git https://my.gitlab.com/group0/group1.git}, err: <nil>
Activity
[-]The repository under multiple groups will not be available.[/-][+]cmd/go: The repository under multiple groups will not be available.[/+]toothrot commentedon Dec 11, 2020
/cc @bcmills @jayconrod @matloob
bcmills commentedon Dec 11, 2020
It looks like your server returned the wrong
go-import
meta tags for this path — this does not seem to be a bug incmd/go
. You'll need to open a ticket with whoever maintains your server (or perhaps with GitLab).bcmills commentedon Dec 11, 2020
See https://golang.org/ref/mod#vcs-find for documentation on the
go-import
protocol.