fswatch

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 5 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 reports file changes below directories without holding a descriptor per watched file.

macOS uses one FSEvents stream per watched root. Other systems use fsnotify: inotify holds one watch per directory and Windows one handle per directory. fsnotify's kqueue backend is not used on macOS because it opens every file of a watched directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Path string
	Lost bool
}

Event names one changed path. Lost is set when the path was a directory added with Dir whose watch ended because it was removed or renamed; add it again once it exists.

type Watcher

type Watcher struct {
	Events chan []Event
	// Errors reports a backend failure such as an overflowed event queue;
	// changes may have been missed.
	Errors chan error
	// contains filtered or unexported fields
}

Watcher delivers changed paths in batches. Events and Errors close after Close.

func New

func New() (*Watcher, error)

New starts a watcher without watches.

func (*Watcher) Close

func (watcher *Watcher) Close() error

Close ends every watch and closes Events and Errors.

func (*Watcher) Dir

func (watcher *Watcher) Dir(_, dir string) error

Dir watches the entries of one directory. root is the directory tree that holds it; it matters only on macOS, where one stream on root serves every directory added under it.

func (*Watcher) Drop

func (watcher *Watcher) Drop(dir string)

Drop ends the watch of a directory added with Dir.

func (*Watcher) Tree

func (watcher *Watcher) Tree(root string) error

Tree watches root and everything below it, now and later. Symbolic links are not followed.

Jump to

Keyboard shortcuts

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