gopathwalk: don't log for nonexistant root dirs

If users don't have a module cache yet, or put a nonexistant directory
in their GOPATH, it doesn't make sense to print an error. Just ignore it
and move on.

No tests; I don't think it makes sense to set up log scraping for this.

Change-Id: I90719297ade37999e8b401767a0a37c940828c27
Reviewed-on: https://go-review.googlesource.com/c/142977
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/gopathwalk/walk.go b/internal/gopathwalk/walk.go
index 15587ab..dc085fc 100644
--- a/internal/gopathwalk/walk.go
+++ b/internal/gopathwalk/walk.go
@@ -63,6 +63,12 @@
 }
 
 func walkDir(root Root, add func(Root, string), opts Options) {
+	if _, err := os.Stat(root.Path); os.IsNotExist(err) {
+		if opts.Debug {
+			log.Printf("skipping nonexistant directory: %v", root.Path)
+		}
+		return
+	}
 	if opts.Debug {
 		log.Printf("scanning %s", root.Path)
 	}
@@ -73,11 +79,11 @@
 	}
 	w.init()
 	if err := fastwalk.Walk(root.Path, w.walk); err != nil {
-		log.Printf("goimports: scanning directory %v: %v", root.Path, err)
+		log.Printf("gopathwalk: scanning directory %v: %v", root.Path, err)
 	}
 
 	if opts.Debug {
-		defer log.Printf("scanned %s", root.Path)
+		log.Printf("scanned %s", root.Path)
 	}
 }