Skip to content

Commit 65b89c3

Browse files
author
Jay Conrod
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 4d9dd35 commit 65b89c3

13 files changed

+610
-362
lines changed

src/cmd/go/alldocs.go

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/modfetch/codehost/vcs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ import (
2929
// The caller should report this error instead of continuing to probe
3030
// other possible module paths.
3131
//
32-
// TODO(bcmills): See if we can invert this. (Return a distinguished error for
33-
// “repo not found” and treat everything else as terminal.)
32+
// TODO(golang.org/issue/31730): See if we can invert this. (Return a
33+
// distinguished error for “repo not found” and treat everything else
34+
// as terminal.)
3435
type VCSError struct {
3536
Err error
3637
}

0 commit comments

Comments
 (0)