Skip to content

dunglas/go-fswatch

go-fswatch: Go bindings for libfswatch

Go Reference

Go bindings for libfswatch.

libfswatch provides comprehensive, cross-platform file change monitoring capabilities.

Features

go-fswatch exposes all features provided by fswatch and libfswatch through an idiomatic Go API:

  • cross-platform: inotify (Linux), FSEvents (macOS), Windows, kqueue (*BSD), File Events Notification (Solaris) and polling
  • watch files and directories
  • recursive watching
  • file and directory filtering (using regular expressions)
  • events filtering

Install

First, install libfswatch:

  1. Download the latest release (fswatch-<version>.tar.gz)
  2. Compile and install libfswatch:
tar xzf fswatch-*.tar.gz
cd fswatch-*
./configure
make
sudo make install

Then, you can use this Go module as usual:

go get github.com/dunglas/go-fswatch

Usage and Examples

See the documentation.

Cgo

This package depends on cgo. If you are looking for non-cgo alternatives, see:

  • fsnotify (doesn't support FSEvents nor polling)
  • notify (doesn't support include/exclude filters)

Credits

Created by Kévin Dunglas and sponsored by Les-Tilleuls.coop.