Skip to content

Commit

Permalink
resolvePaths: dereference root path symlink
Browse files Browse the repository at this point in the history
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 <ross.b.brattain@intel.com>
  • Loading branch information
Ross Brattain authored and alecthomas committed Nov 2, 2018
1 parent 8483257 commit e8d8012
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e8d8012

Please sign in to comment.