Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultSkippedPaths = []string{"node_modules", "testdata", "vendor"}
DefaultSkipped is a list of paths that will be skipped by Watcher.
Functions ¶
This section is empty.
Types ¶
type EventBatch ¶
EventBatch published by Watcher when changes to Go source files are detected within watched directories.
func (EventBatch) Paths ¶
func (e EventBatch) Paths() []string
Paths returns unique file paths in event batch.
type Option ¶
type Option func(*Watcher)
Option configures a Watcher.
func WithBatchInterval ¶
WithBatchInterval configures a Watcher to use interval for event batches.
By default, watcher checks every 250ms if file events are ready to be published in a batch.
func WithLogger ¶
WithLogger configures Watcher to use given logger.
func WithSkipPaths ¶
WithSkipPaths configures Watcher with additional paths to skip.
Paths in DefaultSkippedPaths will always be skipped, as well as paths prefixed with `.` like `.git`.
type Watcher ¶
type Watcher struct { Events chan *EventBatch // contains filtered or unexported fields }
Watcher watches a directory, and its sub directories, for changes to Go source files and publishes the events over a channel for other components to take action on them.
func New ¶
New Watcher to monitor a directory and its sub directories for changes to Go source files.
This function only constructs the Watcher. Call Watcher.Watch to start the actual monitoring.
func (*Watcher) Watch ¶
Watch for changes to Go source files within the root directory and its sub directories.
All paths prefixed with `.`, like `.git`, as well as paths defined in DefaultSkippedPaths are automatically skipped by the watcher. Additional paths can be added to the skip list with the WithSkipPaths option.
If new directories are created within the root directory while Watcher is monitoring, they are automatically added to the watch list, unless they match a path to skip.