watch

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package watch provides file watching for automatic re-linting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Paths are the files or directories to watch.
	Paths []string

	// Recursive watches directories recursively.
	Recursive bool

	// Debounce is the duration to wait before triggering callback.
	// Multiple events within this window are coalesced.
	Debounce time.Duration

	// Include patterns for files to watch.
	Include []string

	// Exclude patterns for files to ignore.
	Exclude []string
}

Config configures the watcher.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default watcher configuration.

type Event

type Event struct {
	// Path is the path to the changed file.
	Path string

	// Op is the operation that triggered the event.
	Op fsnotify.Op

	// Time is when the event occurred.
	Time time.Time
}

Event represents a file change event.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher watches files for changes and triggers callbacks.

func New

func New(cfg *Config) (*Watcher, error)

New creates a new file watcher.

func (*Watcher) Close

func (w *Watcher) Close() error

Close closes the watcher.

func (*Watcher) OnChange

func (w *Watcher) OnChange(fn func(Event) error)

OnChange sets the callback function for file changes.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) error

Watch starts watching files and blocks until context is cancelled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL