Cross-platform file system notifications for Go
open sourceBSD-3-Clausefree
fsnotify is a Go library that watches files and directories for changes and delivers create, write, remove, rename and chmod events on a channel. It uses each system's own interface: inotify on Linux, kqueue on BSD and macOS, ReadDirectoryChangesW on Windows and FEN on illumos. A watcher is added per directory, and the project recommends watching a file's parent directory rather than the file, since editors often replace files atomically. It needs Go 1.23 or newer.
Problems it solves
- rerun something in my Go program when a config file changes
- watch a directory for new files from Go on Linux, macOS and Windows
- get notified in Go when a file is written or deleted
Features
- Create, write, remove, rename and chmod events on a Go channel
- inotify on Linux, kqueue on BSD and macOS, ReadDirectoryChangesW on Windows, FEN on illumos
- One watcher for many paths, with an errors channel
- Example commands in cmd/fsnotify