watch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package watch is the host-side half of `m watch` (spec §3.1, §9): a save triggered inner loop that re-runs the engine-neutral checks (lint, fmt) on changed files. The run half (compile/test/coverage) is a later, engine-bound stage (4.2) — this package never executes M.

It polls file signatures rather than using inotify/fsnotify, keeping the dependency footprint at zero (minimal-SBOM posture) and staying trivially cross-platform. Polling a dev working set is cheap; fsnotify is a possible future optimization for very large trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Changed []string // created or modified
	Removed []string
}

Event reports the files that changed since the previous scan.

type Lister

type Lister func() ([]string, error)

Lister returns the current set of files to watch (re-evaluated each scan, so newly created files are picked up).

type Watcher

type Watcher struct {
	List     Lister
	Interval time.Duration
}

Watcher polls the files from List every Interval and reports changes.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context, emitBaseline bool, onChange func(Event)) error

Watch scans a baseline, then polls until ctx is done, calling onChange for each non-empty event. If emitBaseline is set, the initial file set is delivered as one Changed event first (so startup checks everything). It returns ctx.Err() when ctx is canceled.

Jump to

Keyboard shortcuts

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