]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: remove ListModules call in runGet
authorJay Conrod <jayconrod@google.com>
Thu, 19 Nov 2020 15:56:35 +0000 (10:56 -0500)
committerJay Conrod <jayconrod@google.com>
Fri, 20 Nov 2020 15:37:42 +0000 (15:37 +0000)
ListModules was used to download .info files so that 'go list -m all'
would succeed later when offline. However, 'go list -m all' may
already fail when offline after 'go mod tidy', so it doesn't make
sense to add complexity to 'go get'.

Instead, remove the ListModules call and fix the test that
accidentally depended on it.

For #42723

Change-Id: I692597cf5ca15c23fa6fc9d2bac4b6e044299482
Reviewed-on: https://go-review.googlesource.com/c/go/+/271577
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/internal/modget/get.go
src/cmd/go/testdata/script/mod_gonoproxy.txt

index 13106de2f247266eca5ac65465d00081552695c9..f2fafa85cb0da9308f8247cb62f1ef6c4a4ae768 100644 (file)
@@ -466,21 +466,6 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
        modload.AllowWriteGoMod()
        modload.WriteGoMod()
        modload.DisallowWriteGoMod()
-
-       // Ensure .info files are cached for each module in the build list.
-       // This ensures 'go list -m all' can succeed later if offline.
-       // 'go get' only loads .info files for queried versions. 'go list -m' needs
-       // them to add timestamps to the output.
-       //
-       // This is best effort since build commands don't need .info files to load
-       // the build list.
-       //
-       // TODO(golang.org/issue/40775): ListModules resets modload.loader, which
-       // contains information about direct dependencies that WriteGoMod uses.
-       // Refactor to avoid these kinds of global side effects.
-       if modload.HasModRoot() {
-               modload.ListModules(ctx, []string{"all"}, false, false, false)
-       }
 }
 
 // parseArgs parses command-line arguments and reports errors.
index 7ead946c24a06b7ba2c27649644deda641cfb7f6..546605da216d1028393368388f09b98353ce5f57 100644 (file)
@@ -18,6 +18,12 @@ env GOPRIVATE='*/quote,*/*mple*,golang.org/x'
 env GONOPROXY=none # that is, proxy all despite GOPRIVATE
 go get -d rsc.io/quote
 
+# Download .info files needed for 'go list -m all' later.
+# TODO(#42723): either 'go list -m' should not read these files,
+# or 'go get' and 'go mod tidy' should download them.
+go list -m all  
+stdout '^golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c$'
+
 # When GOPROXY is not empty but contains no entries, an error should be reported.
 env GOPROXY=','
 ! go get -d golang.org/x/text