aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modget/get.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-09-10 08:43:21 -0400
committerBryan C. Mills <bcmills@google.com>2020-09-22 17:59:55 +0000
commitea42b771e9f0726b0e10278df0b5759b984e9cc3 (patch)
tree5b57328e37d0ec7eb140ba0381f891da82c0eedf /src/cmd/go/internal/modget/get.go
parent3aa09489ab3aa13a3ac78b1ff012b148ffffe367 (diff)
downloadgo-ea42b771e9f0726b0e10278df0b5759b984e9cc3.tar.gz
go-ea42b771e9f0726b0e10278df0b5759b984e9cc3.zip
cmd/go/internal/modget: diagnose missing transitive dependencies
For #41315 Change-Id: I3989bcb051ae57dd2d8f89759d241d4cdce49659 Reviewed-on: https://go-review.googlesource.com/c/go/+/255969 Trust: Bryan C. Mills <bcmills@google.com> Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modget/get.go')
-rw-r--r--src/cmd/go/internal/modget/get.go25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go
index 52e3ec84fb..7e573bacb7 100644
--- a/src/cmd/go/internal/modget/get.go
+++ b/src/cmd/go/internal/modget/get.go
@@ -482,14 +482,6 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
}
prevBuildList = buildList
}
- if *getD {
- // Only print warnings after the last iteration, and only if we aren't going
- // to build (to avoid doubled warnings).
- //
- // Only local patterns in the main module, such as './...', can be unmatched.
- // (See the mod_get_nopkgs test for more detail.)
- search.WarnUnmatched(matches)
- }
// Handle downgrades.
var down []module.Version
@@ -579,6 +571,23 @@ func runGet(ctx context.Context, cmd *base.Command, args []string) {
base.Fatalf("%v", buf.String())
}
+ if len(pkgPatterns) > 0 || len(args) == 0 {
+ // Before we write the updated go.mod file, reload the requested packages to
+ // check for errors.
+ loadOpts := modload.PackageOpts{
+ Tags: imports.AnyTags(),
+ LoadTests: *getT,
+
+ // Only print warnings after the last iteration, and only if we aren't going
+ // to build (to avoid doubled warnings).
+ //
+ // Only local patterns in the main module, such as './...', can be unmatched.
+ // (See the mod_get_nopkgs test for more detail.)
+ SilenceUnmatchedWarnings: !*getD,
+ }
+ modload.LoadPackages(ctx, loadOpts, pkgPatterns...)
+ }
+
// Everything succeeded. Update go.mod.
modload.AllowWriteGoMod()
modload.WriteGoMod()