Help us shape the future of Go! Take the 2026 Go Developer Survey

watch

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package watch re-renders a directory's context document when files change.

Index

Constants

View Source
const DefaultInterval = 500 * time.Millisecond

DefaultInterval is the debounce window applied to bursts of file events.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Options) error

Run watches the tree rooted at Root and calls OnChange after each burst of file events, blocking until ctx is canceled or an unrecoverable error occurs.

Types

type Options

type Options struct {
	// Root is the directory tree to watch.
	Root string
	// Ignore reports whether path should not trigger a re-render or be
	// followed as a directory. Called with absolute paths.
	Ignore func(path string) bool
	// Interval is the debounce window; zero uses DefaultInterval.
	Interval time.Duration
	// OnChange re-renders the document after a quiet period. Called from the
	// watch loop, so it must not block indefinitely.
	OnChange func() error
}

Options configures a Watcher.

Jump to

Keyboard shortcuts

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