https://github.com/dimfeld/treewatcher
Recursive Filesystem Tree Watcher for Go
https://github.com/dimfeld/treewatcher
Last synced: over 1 year ago
JSON representation
Recursive Filesystem Tree Watcher for Go
- Host: GitHub
- URL: https://github.com/dimfeld/treewatcher
- Owner: dimfeld
- License: mit
- Created: 2014-05-16T17:26:27.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-12-16T04:46:13.000Z (over 11 years ago)
- Last Synced: 2025-02-08T08:09:57.928Z (over 1 year ago)
- Language: Go
- Size: 130 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
treewatcher [](https://travis-ci.org/dimfeld/treewatcher) [](http://godoc.org/github.com/dimfeld/treewatcher)
===========
Recursive Filesystem Tree Watcher for Go
This is a wrapper around the fsnotify functionality from [howeyc/fsnotify](https://github.com/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.
## Usage
````go
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](https://github.com/dimfeld/simpleblog/blob/master/fswatcher.go).