]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.13] cmd/go: suppress more errors in package-to-module loading
authorBryan C. Mills <bcmills@google.com>
Tue, 8 Oct 2019 18:23:43 +0000 (14:23 -0400)
committerAlexander Rakoczy <alex@golang.org>
Wed, 9 Oct 2019 15:10:17 +0000 (15:10 +0000)
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 <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 421d35cf69f4a18edf96004ba99c01e629a0f79f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/199997

src/cmd/go/internal/modload/query.go
src/cmd/go/testdata/script/mod_get_major.txt

index 0359470d95e80071a156ab6a47a2d059c22c1f4e..75c18f25cc1e3bdf4c82408df04122161ad5af78 100644 (file)
@@ -472,10 +472,10 @@ func queryPrefixModules(candidateModules []string, queryModule func(path string)
                                        notExistErr = rErr
                                }
                        } else if err == nil {
-                               if len(found) > 0 {
-                                       // golang.org/issue/34094: If we have already found a module
-                                       // containing the target package, ignore errors for modules with
-                                       // shorter paths.
+                               if len(found) > 0 || noPackage != nil {
+                                       // golang.org/issue/34094: If we have already found a module that
+                                       // could potentially contain the target package, ignore unclassified
+                                       // errors for modules with shorter paths.
 
                                        // golang.org/issue/34383 is a special case of this: if we have
                                        // already found example.com/foo/v2@v2.0.0 with a matching go.mod
index dd1cbe01a32dca7134d45d88fa6db7daf35cd5a2..367ede9ded45ba5278d47437a4c989bdf44fb2d9 100644 (file)
@@ -13,6 +13,11 @@ go get -d vcs-test.golang.org/git/v3pkg.git/v3@v3.0.0
 go list -m vcs-test.golang.org/git/v3pkg.git/v3
 stdout '^vcs-test.golang.org/git/v3pkg.git/v3 v3.0.0$'
 
+go get -d vcs-test.golang.org/git/empty-v2-without-v1.git/v2@v2.0.0
+
+go list -m vcs-test.golang.org/git/empty-v2-without-v1.git/v2
+stdout '^vcs-test.golang.org/git/empty-v2-without-v1.git/v2 v2.0.0$'
+
 -- go.mod --
 module example.com
 go 1.13