]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal: factor out modload.QueryPackage and use in in modget
authorBryan C. Mills <bcmills@google.com>
Mon, 6 Aug 2018 20:59:31 +0000 (16:59 -0400)
committerBryan C. Mills <bcmills@google.com>
Thu, 9 Aug 2018 21:00:53 +0000 (21:00 +0000)
commit261609f661fcade93f24b9a849638ce8410070cb
tree48547333ff79837973197f7a31cf5b8c978d7534
parenta1cbbe0de6eeb5995cf4cbe01f1e96b17b9fc5db
cmd/go/internal: factor out modload.QueryPackage and use in in modget

modload.Import contains a loop that looks for the module containing a package.
Because we overload Import to locate both packages and modules, that loop
contains a bunch of special-cases for modules with empty roots.

In this change, we factor out the loop into a new function (QueryPackage) and
use that directly in modget.getQuery. That restores the invariant that
the paths passed to modload.Import must be importable packages, and fixes 'go
get' lookups for packages that have moved between a module and submodules with
the same path prefix.

Updates #26602.

Change-Id: I8bc8340c17f2df062d03ce720f4dc18b2ba406b2
Reviewed-on: https://go-review.googlesource.com/128136
Reviewed-by: Russ Cox <rsc@golang.org>
14 files changed:
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modload/import.go
src/cmd/go/internal/modload/query.go
src/cmd/go/testdata/mod/example.com_join_subpkg_v1.0.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_join_subpkg_v1.1.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_join_v1.0.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_join_v1.1.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_split_subpkg_v1.1.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_split_v1.0.0.txt [new file with mode: 0644]
src/cmd/go/testdata/mod/example.com_split_v1.1.0.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_bad_domain.txt
src/cmd/go/testdata/script/mod_get_indirect.txt
src/cmd/go/testdata/script/mod_get_local.txt
src/cmd/go/testdata/script/mod_get_moved.txt [new file with mode: 0644]