aboutsummaryrefslogtreecommitdiff
path: root/imports
diff options
context:
space:
mode:
authorHeschi Kreinick <heschi@google.com>2020-02-28 17:03:27 -0500
committerRebecca Stambler <rstambler@golang.org>2020-03-03 16:59:18 +0000
commit5bcca83a78812bd91ce8cb29be4fc4521cdc8f6f (patch)
tree1d0bcbb223d78f5dfa5f390e7b61404c603ce3ef /imports
parent9b52d559c6099a25c1e7b2b4b3d14a51a3463215 (diff)
downloadgolang-x-tools-5bcca83a78812bd91ce8cb29be4fc4521cdc8f6f.tar.gz
internal: rationalize debug logging
In all cases, use a Logf field to configure debug logging. Non-nil means that logging is enabled through the given function. Fixes accidental debug spam from goimports, which had a separate Debug flag that was supposed to guard logging, but wasn't used when creating the gocommand.Invocation. Change-Id: I448fa282111db556ac2e49801268d0affc19ae30 Reviewed-on: https://go-review.googlesource.com/c/tools/+/221557 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Diffstat (limited to 'imports')
-rw-r--r--imports/forward.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/imports/forward.go b/imports/forward.go
index b4f428767..dbe5b49a9 100644
--- a/imports/forward.go
+++ b/imports/forward.go
@@ -4,6 +4,7 @@ package imports // import "golang.org/x/tools/imports"
import (
"go/build"
+ "log"
"os"
intimp "golang.org/x/tools/internal/imports"
@@ -47,7 +48,6 @@ func Process(filename string, src []byte, opt *Options) ([]byte, error) {
GO111MODULE: os.Getenv("GO111MODULE"),
GOPROXY: os.Getenv("GOPROXY"),
GOSUMDB: os.Getenv("GOSUMDB"),
- Debug: Debug,
LocalPrefix: LocalPrefix,
},
AllErrors: opt.AllErrors,
@@ -57,6 +57,9 @@ func Process(filename string, src []byte, opt *Options) ([]byte, error) {
TabIndent: opt.TabIndent,
TabWidth: opt.TabWidth,
}
+ if Debug {
+ intopt.Env.Logf = log.Printf
+ }
return intimp.Process(filename, src, intopt)
}