зеркало из https://github.com/golang/tools.git
internal/gopathwalk: use opts.Logf for errors if set
Change-Id: Ic963c179a9fda8f7c5c6220a7e4558cccff374be Reviewed-on: https://go-review.googlesource.com/c/tools/+/508505 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Родитель
1ca21856af
Коммит
67d73b2960
|
@ -9,7 +9,6 @@ package gopathwalk
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -77,7 +76,7 @@ func walkDir(root Root, add func(Root, string), skip func(root Root, dir string)
|
|||
}
|
||||
start := time.Now()
|
||||
if opts.Logf != nil {
|
||||
opts.Logf("gopathwalk: scanning %s", root.Path)
|
||||
opts.Logf("scanning %s", root.Path)
|
||||
}
|
||||
w := &walker{
|
||||
root: root,
|
||||
|
@ -87,11 +86,15 @@ func walkDir(root Root, add func(Root, string), skip func(root Root, dir string)
|
|||
}
|
||||
w.init()
|
||||
if err := fastwalk.Walk(root.Path, w.walk); err != nil {
|
||||
log.Printf("gopathwalk: scanning directory %v: %v", root.Path, err)
|
||||
logf := opts.Logf
|
||||
if logf == nil {
|
||||
logf = log.Printf
|
||||
}
|
||||
logf("scanning directory %v: %v", root.Path, err)
|
||||
}
|
||||
|
||||
if opts.Logf != nil {
|
||||
opts.Logf("gopathwalk: scanned %s in %v", root.Path, time.Since(start))
|
||||
opts.Logf("scanned %s in %v", root.Path, time.Since(start))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +224,11 @@ func (w *walker) walk(path string, typ os.FileMode) error {
|
|||
func (w *walker) shouldTraverse(path string) bool {
|
||||
ts, err := os.Stat(path)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
logf := w.opts.Logf
|
||||
if logf == nil {
|
||||
logf = log.Printf
|
||||
}
|
||||
logf("%v", err)
|
||||
return false
|
||||
}
|
||||
if !ts.IsDir() {
|
||||
|
|
|
@ -1292,7 +1292,7 @@ import (
|
|||
func BenchmarkScanModCache(b *testing.B) {
|
||||
env := &ProcessEnv{
|
||||
GocmdRunner: &gocommand.Runner{},
|
||||
Logf: log.Printf,
|
||||
Logf: b.Logf,
|
||||
}
|
||||
exclude := []gopathwalk.RootType{gopathwalk.RootGOROOT}
|
||||
resolver, err := env.GetResolver()
|
||||
|
|
Загрузка…
Ссылка в новой задаче