Created
March 21, 2012 16:06
-
-
Save mikespook/2149050 to your computer and use it in GitHub Desktop.
inotify with pathes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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