Skip to content

Commit 842a1e7

Browse files
Bryan C. Millstoothrot
Bryan C. Mills
authored andcommitted
[release-branch.go1.13] cmd/go: suppress more errors in package-to-module loading
In CL 197059, I suppressed errors if the target package was already found. However, that does not cover the case of passing a '/v2' module path to 'go get' when the module does not contain a package at its root. This CL is a minimal fix for that case, intended to be backportable to 1.13. (Longer term, I intend to rework the version-validation check to treat all mismatched paths as ErrNotExist.) Updates #34746 Fixes #34747 Change-Id: Ia963c2ea00fae424812b8f46a4d6c2c668252147 Reviewed-on: https://go-review.googlesource.com/c/go/+/199839 Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> (cherry picked from commit 421d35c) Reviewed-on: https://go-review.googlesource.com/c/go/+/199997
1 parent 2f73eed commit 842a1e7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/cmd/go/internal/modload/query.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,10 @@ func queryPrefixModules(candidateModules []string, queryModule func(path string)
472472
notExistErr = rErr
473473
}
474474
} else if err == nil {
475-
if len(found) > 0 {
476-
// golang.org/issue/34094: If we have already found a module
477-
// containing the target package, ignore errors for modules with
478-
// shorter paths.
475+
if len(found) > 0 || noPackage != nil {
476+
// golang.org/issue/34094: If we have already found a module that
477+
// could potentially contain the target package, ignore unclassified
478+
// errors for modules with shorter paths.
479479

480480
// golang.org/issue/34383 is a special case of this: if we have
481481
// already found example.com/foo/[email protected] with a matching go.mod

src/cmd/go/testdata/script/mod_get_major.txt

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ go get -d vcs-test.golang.org/git/v3pkg.git/[email protected]
1313
go list -m vcs-test.golang.org/git/v3pkg.git/v3
1414
stdout '^vcs-test.golang.org/git/v3pkg.git/v3 v3.0.0$'
1515

16+
go get -d vcs-test.golang.org/git/empty-v2-without-v1.git/[email protected]
17+
18+
go list -m vcs-test.golang.org/git/empty-v2-without-v1.git/v2
19+
stdout '^vcs-test.golang.org/git/empty-v2-without-v1.git/v2 v2.0.0$'
20+
1621
-- go.mod --
1722
module example.com
1823
go 1.13

0 commit comments

Comments
 (0)