Recursive Filesystem Tree Watcher for Go
This is a wrapper around the fsnotify functionality from howeyc/fsnotify.
It exposes a similar interface, with an Event channel and an Error channel. All data read from the fsnotify object is passed through to the client.
When the TreeWatcher sees that a directory was added, it automatically starts watching that directory and all directories under it.
tw = treewatcher.New()
defer tw.Close()
tw.WatchTree("/tmp")
for {
select {
event := <- tw.Event:
handleEvent(event)
error := <- tw.Error:
panic(error)
}
}
For a real usage example, see dimfeld/simpleblog/fswatcher.go.