Documentation
¶
Overview ¶
Package watch implements the daemon mode: format every source file as soon as anything finishes writing it.
Three things make this safe, and all three are things hand-rolled watchexec/entr pipelines get wrong:
- Self-writes are recognised by content, not by timing. See internal/engine/selfwrite.go.
- A file is only formatted once it has stopped changing. The debounce timer is reset by every new event, and after it fires the file is read twice with a settle gap; if the two reads differ, the write is still in progress and the timer starts again.
- Even if both of those were defeated, a partially written file does not parse, the formatter exits non-zero, and the engine writes nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Debounce is how long a file must be quiet before it is formatted.
Debounce time.Duration
// Settle is the gap between the two verification reads.
Settle time.Duration
// Workers bounds concurrent formatting.
Workers int
// OnResult is called for every file the watcher acts on.
OnResult func(engine.Result)
// OnReady is called once the initial tree walk has finished and the
// watcher is live.
OnReady func(dirs int)
// Log receives progress.
Log engine.Logger
}
Options tune the watcher.