# README
watcher
import "github.com/cognusion/go-jar/watcher"
Overview
Package watcher is used to keep an eye on file system events, and trigger actions when those events are of interest.
Index
Package files
Variables
var (
// DebugOut is a log.Logger for debug messages
DebugOut = log.New(io.Discard, "[DEBUG] ", 0)
// ErrorOut is a log.Logger for error messages
ErrorOut = log.New(io.Discard, "", 0)
)
type WatchHandlerFunc
type WatchHandlerFunc func(fsnotify.Event)
WatchHandlerFunc takes an fsnotify.Event to add on. A WatchHandlerFunc can assume it will not be called more than once while running
type Watcher
type Watcher struct {
// Close should be called when the Watcher is no longer of use. It is safe to call multiple times.
Close func()
// contains filtered or unexported fields
}
Watcher is an implementation of fsnotify.Watcher with some rails and opinions.
func NewWatcher
func NewWatcher() (*Watcher, error)
NewWatcher returns a Watcher or an error if a problem occurred creating it (very rare)
func NewWatcherWithErrorChan
func NewWatcherWithErrorChan(errorChan chan error) (*Watcher, error)
NewWatcherWithErrorChan returns a Watcher or an error if a problem occurred creating it (very rare). The supplied chan will receive non-nil errors if they occur
func (*Watcher) Add
func (w *Watcher) Add(file string, wf WatchHandlerFunc) error
Add takes a filename, and a WatchHandlerFunc to call if the file changes
func (*Watcher) Delete
func (w *Watcher) Delete(file string) error
Delete takes a filename, and removes it from being watched
Generated by godoc2md