Documentation
¶
Overview ¶
Package fswatch watches a directory tree and reports which directories changed. fsnotify has no recursive watch, so the watcher holds one watch per directory and keeps that set in step with the tree. It reports directories rather than files because its consumer re-reads a changed directory instead of applying event deltas.
Symbolic links below the root are not followed: a linked directory is neither walked nor watched. The root itself may be a link. Directories whose names start with "." are not watched, which keeps .git, .obsidian, and .hive out of the set.
Index ¶
Constants ¶
const DefaultDebounce = 100 * time.Millisecond
DefaultDebounce coalesces the write, rename, and chmod burst of one editor save into one Change, and so into one rescan.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
Change lists the absolute directories whose listing or files changed since the previous Change, sorted. A created directory is listed itself as well as through its parent: files written into it before its watch existed produced no events, so the consumer has to read it.
Resync reports that the kernel dropped events, so Dirs lists every watched directory and the consumer must re-read everything it holds, not only those directories' listings.
type Option ¶
type Option func(*options)
func WithDebounce ¶
WithDebounce sets the window that collects events into one Change. The window opens at the first event after the previous one closed and closes d later, so a continuous writer still yields a Change every d. Default DefaultDebounce.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher delivers one Change per debounce window on an unbuffered channel. It never blocks on its consumer: windows that close while the consumer is busy merge into the Change it receives next.
When the root itself is removed or renamed, the watcher stops and Changes closes, as after Close: every watch is gone with the root, and a new one can only be added once something creates the root again. The consumer starts a new Watcher then.