A no-nonsense wrapper around the fsnotify package.
$ go get github.com/wilhelm-murdoch/go-watcher
New creates a new instance of a Watcher struct.
AddFile adds a single valid file to the current Watcher instance and returns an error if the file is not valid.
AddDir will recursively walk the specified directory tree and add all valid files to the current watcher instance for monitoring.
AddGlob will monitor the specified "glob" pattern and add all valid files to the current watcher instance for monitoring.
func (w *Watcher) On(event fsnotify.Op, f func(fsnotify.Event, os.FileInfo, error) error) error
#watcher.go:75:94
#
On fires off an assigned callback for each event type. Only specified events are supported and all will return either nil or an error. Every watcher instance exits when it first encounters an error.
All will fire off the specified callback on any supported fsnotify
event.
Watch creates a new errgroup
instance and monitors for changes to any of the specified files. All supported event types will fire off specified callbacks if available. This method exits on the first encountered error.
package main
import (
"fmt"
"strings"
"github.com/wilhelm-murdoch/go-play"
)
func main() {
}
List is a wrapper around fsnotify.Watchlist()
. It returns a list of strings representing all files and directories currently monitored instance of fsnotify
.
Done signals a blocking channel that processing is complete and that we can safely exit the current watcher instance.
Documentation generated by Gadget.
Copyright © 2022 Wilhelm Murdoch.
This project is MIT licensed.