diff options
author | Bryan C. Mills <bcmills@google.com> | 2019-11-01 12:06:24 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-11-01 20:38:31 +0000 |
commit | 617b4168b8c6b11269a22646f0743ce43fb5a321 (patch) | |
tree | dcd22bcc1cf92030aa00ebb249467081ef06eb7b /src/cmd/go/internal/modload/query.go | |
parent | c9d89f6bacd66d4765cf36d2a4b121392921c5ed (diff) | |
download | go-617b4168b8c6b11269a22646f0743ce43fb5a321.tar.gz go-617b4168b8c6b11269a22646f0743ce43fb5a321.zip |
cmd/go: adjust module-related logging
Suppress “finding” messages unless they are unusually slow, and
“extracting” messages always (they almost always occur conjunction
with “downloading”, which is already logged).
Log “found” messages for module dependencies added to satisfy missing
import paths.
Log top-level version changes in 'go get' when the selected version
is not identical to the version requested on the command line.
Updates #26152
Updates #33284
Change-Id: I4d0de60fab58d7cc7df8a2aff05c8b5b2220e626
Reviewed-on: https://go-review.googlesource.com/c/go/+/204777
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/query.go')
-rw-r--r-- | src/cmd/go/internal/modload/query.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index 976d35665d..1b8b2d0cbc 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -12,6 +12,7 @@ import ( "strings" "sync" + "cmd/go/internal/cfg" "cmd/go/internal/imports" "cmd/go/internal/modfetch" "cmd/go/internal/search" @@ -62,10 +63,24 @@ func Query(path, query, current string, allowed func(module.Version) bool) (*mod return info, err } +var errQueryDisabled error = queryDisabledError{} + +type queryDisabledError struct{} + +func (queryDisabledError) Error() string { + if cfg.BuildModReason == "" { + return fmt.Sprintf("cannot query module due to -mod=%s", cfg.BuildMod) + } + return fmt.Sprintf("cannot query module due to -mod=%s\n\t(%s)", cfg.BuildMod, cfg.BuildModReason) +} + func queryProxy(proxy, path, query, current string, allowed func(module.Version) bool) (*modfetch.RevInfo, error) { if current != "" && !semver.IsValid(current) { return nil, fmt.Errorf("invalid previous version %q", current) } + if cfg.BuildMod != "" && cfg.BuildMod != "mod" { + return nil, errQueryDisabled + } if allowed == nil { allowed = func(module.Version) bool { return true } } |