Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fsnotify
✓ gopkg.in/fsnotify/fsnotify.v1
Watch a directory for file system events using fsnotify.
package main
import (
"log"
"gopkg.in/fsnotify/fsnotify.v1"
)
func main() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()
done := make(chan bool)
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
log.Println("event:", event)
case err, ok := <-watcher.Errors:
if !ok {
return
}
log.Println("error:", err)
}
}
}()
err = watcher.Add("/tmp")
if err != nil {
log.Fatal(err)
}
<-done
}
Upgrade
Version history
1.4.7latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.