Installation
Requirements
Section titled “Requirements”- Go 1.26 or later
- An active Go module (
go.mod)
Install
Section titled “Install”Run this in your project directory:
go get github.com/larsartmann/go-filewatcher/v2@latestQuick Usage
Section titled “Quick Usage”package main
import ( "context" "fmt" "log" "time"
filewatcher "github.com/larsartmann/go-filewatcher/v2")
func main() { watcher, err := filewatcher.New( []string{"./src"}, filewatcher.WithExtensions(".go"), filewatcher.WithDebounce(500*time.Millisecond), ) if err != nil { log.Fatal(err) } defer watcher.Close()
events, err := watcher.Watch(context.Background()) if err != nil { log.Fatal(err) }
for event := range events { fmt.Printf("%s: %s\n", event.Op, event.Path) }}Verify Installation
Section titled “Verify Installation”go list -m github.com/larsartmann/go-filewatcher/v2Next Steps
Section titled “Next Steps”- Follow the Quick Start for complete examples
- Learn about Filtering to control which events you receive
- Explore Middleware for cross-cutting concerns