fswatch

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 8 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

Overview

Package fswatch turns inotify events into coalesced change ticks, the Go counterpart of the `notify` crate watchers the Rust services use (the mail service's recursive maildir watch, the brightness sysfs watch). Consumers only need "something under here changed", so the events themselves are not surfaced: each burst is one tick.

The reader blocks in poll(2) on the inotify fd and an eventfd, so an idle watcher costs nothing and Close wakes it without a timeout.

Index

Constants

Changes is the event mask that counts as a change for a directory tree: files created, written, removed, renamed (maildir flags are renames), or their metadata changed. It matches notify's Create | Modify | Remove kinds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

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

Watcher is one inotify instance.

func New

func New(mask uint32, recursive bool) (*Watcher, error)

New starts a watcher for mask. With recursive set, Add walks the whole tree and directories created later are watched as they appear, which is what a recursive notify watcher does.

func (*Watcher) Add

func (w *Watcher) Add(path string) error

Add watches path (and, recursively, every directory below it).

func (*Watcher) Changed

func (w *Watcher) Changed() <-chan struct{}

Changed ticks once per burst of events; it closes after Close.

func (*Watcher) Close

func (w *Watcher) Close() error

Close stops the reader, releases the fds, and closes Changed.

Jump to

Keyboard shortcuts

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