1
0
mirror of https://github.com/golang/go synced 2024-11-17 06:04:47 -07:00

cmd/go: clarify documentation for 'go get -u'

Also: add a comment in internal/get.newUpgrader as a follow-up to
CL 177677.

Updates #26902

Change-Id: Ibce2807ecb44fa21697ca04a51c44ddca0f661d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/176902
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Jay Conrod 2019-05-13 15:11:31 -04:00
parent 545cd82734
commit a53b465572
2 changed files with 15 additions and 6 deletions

View File

@ -603,9 +603,12 @@
// The -t flag instructs get to consider modules needed to build tests of // The -t flag instructs get to consider modules needed to build tests of
// packages specified on the command line. // packages specified on the command line.
// //
// The -u flag instructs get to update dependencies to use newer minor or // The -u flag instructs get to update modules providing dependencies
// patch releases when available. Continuing the previous example, // of packages named on the command line to use newer minor or patch
// 'go get -u A' will use the latest A with B v1.3.1 (not B v1.2.3). // releases when available. Continuing the previous example, 'go get -u A'
// will use the latest A with B v1.3.1 (not B v1.2.3). If B requires module C,
// but C does not provide any packages needed to build packages in A
// (not including tests), then C will not be updated.
// //
// The -u=patch flag (not -u patch) also instructs get to update dependencies, // The -u=patch flag (not -u patch) also instructs get to update dependencies,
// but changes the default to select patch releases. // but changes the default to select patch releases.

View File

@ -77,9 +77,12 @@ those requirements by taking the maximum requested version.)
The -t flag instructs get to consider modules needed to build tests of The -t flag instructs get to consider modules needed to build tests of
packages specified on the command line. packages specified on the command line.
The -u flag instructs get to update dependencies to use newer minor or The -u flag instructs get to update modules providing dependencies
patch releases when available. Continuing the previous example, of packages named on the command line to use newer minor or patch
'go get -u A' will use the latest A with B v1.3.1 (not B v1.2.3). releases when available. Continuing the previous example, 'go get -u A'
will use the latest A with B v1.3.1 (not B v1.2.3). If B requires module C,
but C does not provide any packages needed to build packages in A
(not including tests), then C will not be updated.
The -u=patch flag (not -u patch) also instructs get to update dependencies, The -u=patch flag (not -u patch) also instructs get to update dependencies,
but changes the default to select patch releases. but changes the default to select patch releases.
@ -757,6 +760,9 @@ func newUpgrader(cmdline map[string]*query, pkgs map[string]bool) *upgrader {
work = work[1:] work = work[1:]
m := modload.PackageModule(pkg) m := modload.PackageModule(pkg)
u.upgrade[m.Path] = true u.upgrade[m.Path] = true
// testImports is empty unless test imports were actually loaded,
// i.e., -t was set or "all" was one of the arguments.
imports, testImports := modload.PackageImports(pkg) imports, testImports := modload.PackageImports(pkg)
for _, imp := range imports { for _, imp := range imports {
add(imp) add(imp)