Using filepath.Clean (BSD and Linux).
// addWatch adds path to the watched file set.
// The flags are interpreted as described in kevent(2).
func (w *Watcher) addWatch(path string, flags uint32) error {
+ path = filepath.Clean(path)
w.mu.Lock()
if w.isClosed {
w.mu.Unlock()
// Remove stops watching the the named file or directory (non-recursively).
func (w *Watcher) Remove(name string) error {
+ name = filepath.Clean(name)
w.wmut.Lock()
watchfd, ok := w.watches[name]
w.wmut.Unlock()
"errors"
"fmt"
"os"
+ "path/filepath"
"strings"
"sync"
"syscall"
// Add starts watching the named file or directory (non-recursively).
func (w *Watcher) Add(name string) error {
+ name = filepath.Clean(name)
if w.isClosed {
return errors.New("inotify instance already closed")
}
// Remove stops watching the the named file or directory (non-recursively).
func (w *Watcher) Remove(name string) error {
+ name = filepath.Clean(name)
w.mu.Lock()
defer w.mu.Unlock()
watch, ok := w.watches[name]