From e8d801238da6f0dfd14078d68f9b53fa50a7eeb5 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Thu, 1 Nov 2018 15:20:50 -0700 Subject: [PATCH] resolvePaths: dereference root path symlink If the root path is a symlink dereference it by appending os.PathSeparator. Then the os.Lstat() in filepath.Walk() will correctly see the directory The root path might be a symlink in order for developers to place a project under GOPATH without modifying GOPATH. Signed-off-by: Ross Brattain --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index f0e659a9..c26cf0c0 100644 --- a/main.go +++ b/main.go @@ -324,6 +324,12 @@ func resolvePaths(paths, skip []string) []string { for _, path := range paths { if strings.HasSuffix(path, "/...") { root := filepath.Dir(path) + if lstat, err := os.Lstat(root); err == nil && (lstat.Mode()&os.ModeSymlink) != 0 { + // if we have a symlink append os.PathSeparator to force a dereference of the symlink + // to workaround bug in filepath.Walk that won't dereference a root path that + // is a dir symlink + root = root + string(os.PathSeparator) + } _ = filepath.Walk(root, func(p string, i os.FileInfo, err error) error { if err != nil { warning("invalid path %q: %s", p, err)