Skip to content

Instantly share code, notes, and snippets.

@mikespook

mikespook/notify.go

Created Mar 21, 2012
Embed
What would you like to do?
inotify with pathes
package main
import (
"exp/inotify"
"log"
"os"
)
func init() {
f, _ := os.OpenFile("notify.log", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)
log.SetOutput(f)
}
func main() {
watcher, err := inotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
err = watcher.Watch("/tmp")
if err != nil {
log.Fatal(err)
}
for {
select {
case ev := <-watcher.Event:
log.Println("event:", ev)
case err := <-watcher.Error:
log.Println("error:", err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.