From 29462195f224219ae1eb9517cbece164b1149dea Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Tue, 9 Aug 2016 14:04:40 -0400 Subject: [PATCH] x/tools/cmd/goimports: define verbose flag in parseFlags This will allow users to use a different flag name. Change-Id: I252871b8efb6867e61ca507f59a9663cb7140b7d Reviewed-on: https://go-review.googlesource.com/26632 Reviewed-by: Brad Fitzpatrick --- cmd/goimports/goimports.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/goimports/goimports.go b/cmd/goimports/goimports.go index 8ab61b8c..fc61ac26 100644 --- a/cmd/goimports/goimports.go +++ b/cmd/goimports/goimports.go @@ -31,7 +31,7 @@ var ( write = flag.Bool("w", false, "write result to (source) file instead of stdout") doDiff = flag.Bool("d", false, "display diffs instead of rewriting files") srcdir = flag.String("srcdir", "", "choose imports as if source code is from `dir`. When operating on a single file, dir may instead be the complete file name.") - verbose = flag.Bool("v", false, "verbose logging") + verbose bool // verbose logging cpuProfile = flag.String("cpuprofile", "", "CPU profile output") memProfile = flag.String("memprofile", "", "memory profile output") @@ -195,6 +195,8 @@ func main() { // parseFlags parses command line flags and returns the paths to process. // It's a var so that custom implementations can replace it in other files. var parseFlags = func() []string { + flag.BoolVar(&verbose, "v", false, "verbose logging") + flag.Parse() return flag.Args() } @@ -243,7 +245,7 @@ func gofmtMain() { }() } - if *verbose { + if verbose { log.SetFlags(log.LstdFlags | log.Lmicroseconds) imports.Debug = true }