watcher

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWatcher

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

FileWatcher uses fsnotify to watch a file's directory for changes.

func NewFileWatcher

func NewFileWatcher(path string) (*FileWatcher, error)

NewFileWatcher creates a watcher using fsnotify. It watches the parent directory to handle atomic saves (vim, VS Code).

func (*FileWatcher) Content

func (fw *FileWatcher) Content() <-chan string

func (*FileWatcher) Start

func (fw *FileWatcher) Start(ctx context.Context) error

type NoopWatcher

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

NoopWatcher is used for stdin input where there's nothing to watch.

func NewNoopWatcher

func NewNoopWatcher() *NoopWatcher

NewNoopWatcher creates a watcher that never sends updates.

func (*NoopWatcher) Content

func (nw *NoopWatcher) Content() <-chan string

func (*NoopWatcher) Start

func (nw *NoopWatcher) Start(ctx context.Context) error

type PollWatcher

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

PollWatcher uses stat-based polling for environments where fsnotify doesn't work.

func NewPollWatcher

func NewPollWatcher(path string, interval time.Duration) *PollWatcher

NewPollWatcher creates a stat-based polling watcher.

func (*PollWatcher) Content

func (pw *PollWatcher) Content() <-chan string

func (*PollWatcher) Start

func (pw *PollWatcher) Start(ctx context.Context) error

type Watcher

type Watcher interface {
	Start(ctx context.Context) error
	Content() <-chan string
}

Watcher watches for file changes and sends updated content.

Jump to

Keyboard shortcuts

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