Resilient file watcher. Used in Bud.
- Watches a directory recursively
- Debounces multiple events into a single function call
- Smooths over differences between operating systems
- Ignores files in your
.gitignore
- Generally does what you'd expect
go get -u github.com/livebud/watcher
package main
import (
"context"
"fmt"
"os"
"github.com/livebud/watcher"
)
func main() {
ctx := context.Background()
if err := run(ctx); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run(ctx context.Context) error {
return watcher.Watch(ctx, ".", func(events []watcher.Event) error {
for _, event := range events {
fmt.Println(string(event.Op), event.Path)
}
return nil
})
}
Thank you for your interest in contributing! To get started, first clone the repo:
git clone https://github.com/livebud/watcher
cd watcher
Next, install the dependencies:
go mod tidy
Finally, try running the tests:
go test ./...
MIT