]> Cypherpunks repositories - gostls13.git/commit
cmd/go: make get -u upgrade only modules providing packages
authorJay Conrod <jayconrod@google.com>
Sun, 21 Apr 2019 19:21:58 +0000 (15:21 -0400)
committerJay Conrod <jayconrod@google.com>
Tue, 30 Apr 2019 22:20:57 +0000 (22:20 +0000)
commit65b89c3542fb3d36632e404f672b41f111b8b60a
tree803a9d73b058db0bc166c8b2d9bf1084ca9ed8ab
parent4d9dd3580624df413d65d83e467fcd6ad4a0168b
cmd/go: make get -u upgrade only modules providing packages

Currently, 'go get -u' upgrades modules matching command line
arguments and any modules they transitively require. 'go get -u' with
no positional arguments upgrades all modules transitively required by
the main module. This usually adds a large number of indirect
requirements, which is surprising to users.

With this change, 'go get' will load packages specified by
its arguments using a similar process to other commands
('go build', etc). Only modules providing packages will be upgraded.

'go get -u' now upgrades modules providing packages transitively
imported by the command-line arguments. 'go get -u' without arguments
will only upgrade modules needed by the package in the current
directory.

'go get -m' will load all packages within a module. 'go get -m -u'
without arguments will upgrade modules needed by the main module. It
is equivalent to 'go get -u all'. Neither command will upgrade modules
that are required but not used.

Note that 'go get -m' and 'go get -d' both download modules in order
to load packages.

Fixes #26902

Change-Id: I2bad686b3ca8c9de985a81fb42b16a36bb4cc3ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/174099
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
13 files changed:
src/cmd/go/alldocs.go
src/cmd/go/internal/modfetch/codehost/vcs.go
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/query.go
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_main.txt
src/cmd/go/testdata/script/mod_get_upgrade.txt
src/cmd/go/testdata/script/mod_load_badchain.txt
src/cmd/go/testdata/script/mod_load_badzip.txt
src/cmd/go/testdata/script/mod_upgrade_patch_mod.txt
src/cmd/go/testdata/script/mod_upgrade_patch_pkg.txt