Documentation
¶
Index ¶
- Variables
- func SameFile(fi1, fi2 os.FileInfo) bool
- type Event
- type Op
- type Watcher
- func (w *Watcher) Add(name string) (err error)
- func (w *Watcher) AddRecursive(name string) (err error)
- func (w *Watcher) Close()
- func (w *Watcher) FilterOps(ops ...Op)
- func (w *Watcher) Ignore(paths ...string) (err error)
- func (w *Watcher) IgnoreHiddenFiles(ignore bool)
- func (w *Watcher) Remove(name string) (err error)
- func (w *Watcher) RemoveRecursive(name string) (err error)
- func (w *Watcher) SetMaxEvents(delta int)
- func (w *Watcher) Start(d time.Duration) error
- func (w *Watcher) TriggerEvent(eventType Op, file os.FileInfo)
- func (w *Watcher) Wait()
- func (w *Watcher) WatchedFiles() map[string]os.FileInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDurationTooShort occurs when calling the watcher's Start // method with a duration that's less than 1 nanosecond. ErrDurationTooShort = errors.New("error: duration is less than 1ns") // ErrWatcherRunning occurs when trying to call the watcher's // Start method and the polling cycle is still already running // from previously calling Start and not yet calling Close. ErrWatcherRunning = errors.New("error: watcher is already running") // ErrWatchedFileDeleted is an error that occurs when a file or folder that was // being watched has been deleted. ErrWatchedFileDeleted = errors.New("error: watched file or folder deleted") )
Functions ¶
Types ¶
type Event ¶
An Event describes an event that is received when files or directory changes occur. It includes the os.FileInfo of the changed file or directory and the type of event that's occurred and the full path of the file.
type Op ¶
type Op uint32
An Op is a type that is used to describe what type of event has occurred during the watching process.
type Watcher ¶
type Watcher struct { Event chan Event Error chan error Closed chan struct{} // contains filtered or unexported fields }
func (*Watcher) AddRecursive ¶
Add adds either a single file or directory recursively to the file list.
func (*Watcher) FilterOps ¶
FilterOps filters which event op types should be returned when an event occurs.
func (*Watcher) Ignore ¶
Ignore adds paths that should be ignored.
For files that are already added, Ignore removes them.
func (*Watcher) IgnoreHiddenFiles ¶
IgnoreHiddenFiles sets the watcher to ignore any file or directory that starts with a dot.
func (*Watcher) RemoveRecursive ¶
Remove removes either a single file or a directory recursively from the file's list.
func (*Watcher) SetMaxEvents ¶
SetMaxEvents controls the maximum amount of events that are sent on the Event channel per watching cycle. If max events is less than 1, there is no limit, which is the default.
func (*Watcher) Start ¶
Start begins the polling cycle which repeats every specified duration until Close is called.
func (*Watcher) TriggerEvent ¶
TriggerEvent is a method that can be used to trigger an event, separate to the file watching process.