Skip to content

Commit

Permalink
[release-branch.go1.13] cmd/go: suppress more errors in package-to-mo…
Browse files Browse the repository at this point in the history
…dule 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
  • Loading branch information
Bryan C. Mills authored and toothrot committed Oct 9, 2019
1 parent 2f73eed commit 842a1e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cmd/go/internal/modload/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected] with a matching go.mod
Expand Down
5 changes: 5 additions & 0 deletions src/cmd/go/testdata/script/mod_get_major.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ go get -d vcs-test.golang.org/git/v3pkg.git/[email protected]
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/[email protected]

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

0 comments on commit 842a1e7

Please sign in to comment.