From: Bryan C. Mills Date: Tue, 5 Mar 2019 14:28:50 +0000 (-0500) Subject: cmd/go/internal/modload: do not fetch modules in searchPackages if -mod=vendor is set X-Git-Tag: go1.13beta1~1213 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e44a031651d042107d446b4038a70c6da763e2d5;p=gostls13.git cmd/go/internal/modload: do not fetch modules in searchPackages if -mod=vendor is set Updates #30228 Updates #30241 Change-Id: I6b5f842d00ba273ed241abe55a1ea71c105ec284 Reviewed-on: https://go-review.googlesource.com/c/go/+/165377 Run-TryBot: Bryan C. Mills TryBot-Result: Gobot Gobot Reviewed-by: Jay Conrod --- diff --git a/src/cmd/go/internal/modload/search.go b/src/cmd/go/internal/modload/search.go index 7d8852d01d..45e7ee2674 100644 --- a/src/cmd/go/internal/modload/search.go +++ b/src/cmd/go/internal/modload/search.go @@ -112,6 +112,11 @@ func matchPackages(pattern string, tags map[string]bool, useStd bool, modules [] walkPkgs(cfg.GOROOTsrc, "") } + if cfg.BuildMod == "vendor" { + walkPkgs(filepath.Join(ModRoot(), "vendor"), "") + return pkgs + } + for _, mod := range modules { if !treeCanMatch(mod.Path) { continue diff --git a/src/cmd/go/testdata/script/mod_vendor_build.txt b/src/cmd/go/testdata/script/mod_vendor_build.txt index 7b304dbb70..01ee2d202a 100644 --- a/src/cmd/go/testdata/script/mod_vendor_build.txt +++ b/src/cmd/go/testdata/script/mod_vendor_build.txt @@ -19,6 +19,12 @@ cmp go.mod go.mod.good go list -mod=vendor cmp go.mod go.mod.good +# With a clean (and empty) module cache, 'go list -mod=vendor' should not download modules. +go clean -modcache +env GOPROXY=off +! go list ... +go list -mod=vendor ... + -- go.mod -- module m