From 0af715838edb38c32e90d5b294f48254274b6ccc Mon Sep 17 00:00:00 2001 From: Atish Patel Date: Sat, 11 Jun 2022 01:21:44 -0400 Subject: [PATCH] Add support for following symlink paths --- watch.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/watch.go b/watch.go index f591a87..2310359 100644 --- a/watch.go +++ b/watch.go @@ -53,6 +53,14 @@ func watch(root string, watcher *fsnotify.Watcher, names chan<- string, done cha func walker(watcher *fsnotify.Watcher, reflexes []*Reflex) filepath.WalkFunc { return func(path string, f os.FileInfo, err error) error { + isSymlink := f.Mode()&os.ModeSymlink != 0 + if isSymlink { + // follow symlink paths + symlinkPath, _ := filepath.EvalSymlinks(path) + if symlinkPath != "" { + return filepath.Walk(symlinkPath, walker(watcher, reflexes)) + } + } if err != nil || !f.IsDir() { return nil }