Skip to content

Instantly share code, notes, and snippets.

@mikespook
Created March 21, 2012 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikespook/2149050 to your computer and use it in GitHub Desktop.
Save mikespook/2149050 to your computer and use it in GitHub Desktop.
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