Documentation
¶
Overview ¶
Package fswatch provides a polling-based file system watcher for Go.
It uses polling (not OS-level events) to detect file changes, which means zero external dependencies. File modification times are tracked via os.Stat, directories are walked with filepath.WalkDir, and glob matching uses filepath.Match from the standard library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
// Path is the absolute path of the affected file.
Path string
// Op is the operation that triggered the event.
Op Op
// ModTime is the last modification time of the file at the time the event was detected.
ModTime time.Time
}
Event represents a file system change event.
type Option ¶
type Option func(*config)
Option configures a Watcher.
func Debounce ¶
Debounce sets the debounce interval. Events are batched and delivered after no new events have been detected for this duration. Default is 500ms.
func Glob ¶
Glob sets file patterns to include (e.g., "*.yaml", "*.go"). Patterns are matched using filepath.Match against the file's base name. If no glob patterns are set, all files are included.
func Ignore ¶
Ignore sets patterns to exclude (e.g., ".git", "*.tmp", "node_modules"). Patterns are matched using filepath.Match against the file's base name.
func PollInterval ¶
PollInterval sets how often the watcher checks for file system changes. Default is 1s.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches directories for file system changes using polling.
func New ¶
New creates a new Watcher with the given options. At least one path must be specified via the Paths option.