mirror of
https://github.com/golang/go
synced 2024-11-18 18:44:42 -07:00
go/packages: use -find, add GOPACKAGESDEBUG env var
Pass -find whenever possible to speed up go list calls. Add an environment variable, GOPACKAGESDEBUG, that controls debug logging so that we don't have to tell users to recompile goimports to debug it. Change-Id: If39ff7829279dafa4e066e74a024c27a8235154b Reviewed-on: https://go-review.googlesource.com/c/155477 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
f344c7530c
commit
d12035dfdc
@ -16,6 +16,7 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -26,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
// debug controls verbose logging.
|
||||
const debug = false
|
||||
var debug, _ = strconv.ParseBool(os.Getenv("GOPACKAGESDEBUG"))
|
||||
|
||||
// A goTooOldError reports that the go command
|
||||
// found by exec.LookPath is too old to use the new go list behavior.
|
||||
@ -711,6 +712,9 @@ func golistargs(cfg *Config, words []string) []string {
|
||||
fmt.Sprintf("-test=%t", cfg.Tests),
|
||||
fmt.Sprintf("-export=%t", usesExportData(cfg)),
|
||||
fmt.Sprintf("-deps=%t", cfg.Mode >= LoadImports),
|
||||
// go list doesn't let you pass -test and -find together,
|
||||
// probably because you'd just get the TestMain.
|
||||
fmt.Sprintf("-find=%t", cfg.Mode < LoadImports && !cfg.Tests),
|
||||
}
|
||||
fullargs = append(fullargs, cfg.BuildFlags...)
|
||||
fullargs = append(fullargs, "--")
|
||||
|
Loading…
Reference in New Issue
Block a user