moddwatch

package module
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 11 Imported by: 0

README

Travis Build Status

ModdWatch is a library for building tools that watch files and directories for modifications.

File watching library for Go backed by libfswatch via CGo. Uses kqueue on macOS and inotify on Linux. Works with Docker volume mounts. Fork of cortesi/moddwatch, used by modd.

Documentation

Index

Constants

View Source
const MaxLullWait = time.Second * 8

MaxLullWait is the maximum time to wait for a lull. This only kicks in if we've had a constant stream of modifications blocking us.

Variables

This section is empty.

Functions

func List

func List(root string, includePatterns, excludePatterns []string) ([]string, error)

List all files under the root that match the specified patterns.

Types

type Event

type Event uint32

Event represents a filesystem event type.

const (
	Create Event = 1 << iota
	Write
	Remove
	Rename
)

type EventInfo

type EventInfo interface {
	Event() Event
	Path() string
	Sys() any
}

EventInfo describes a single filesystem event.

type FSWatcher

type FSWatcher struct {
	Events chan EventInfo
	// contains filtered or unexported fields
}

func NewFSWatcher

func NewFSWatcher() (*FSWatcher, error)

func (*FSWatcher) Add

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

func (*FSWatcher) Done added in v0.2.12

func (w *FSWatcher) Done() <-chan struct{}

func (*FSWatcher) Drain added in v0.2.12

func (w *FSWatcher) Drain(max int) []EventInfo

func (*FSWatcher) Exists added in v0.2.12

func (w *FSWatcher) Exists(path string) bool

func (*FSWatcher) Start

func (w *FSWatcher) Start()

func (*FSWatcher) Stop

func (w *FSWatcher) Stop()

type Mod

type Mod struct {
	Changed []string
	Deleted []string
	Added   []string
}

Mod encapsulates a set of changes.

func (Mod) All

func (mod Mod) All() []string

All returns a single list of all files changed or added : deleted files are not included.

func (Mod) Empty

func (mod Mod) Empty() bool

func (Mod) Filter

func (mod Mod) Filter(includes, excludes []string) (*Mod, error)

Filter applies a filter, returning a new Mod structure.

func (Mod) Has

func (mod Mod) Has(p string) bool

Has checks if a given Mod includes a specified file.

func (Mod) Join

func (mod Mod) Join(b Mod) Mod

Join two Mods together, resulting in a new structure where each list is sorted alphabetically.

func (Mod) String

func (mod Mod) String() string

type Watcher

type Watcher struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func Watch

func Watch(root string, includes, excludes []string, lullTime time.Duration, ch chan *Mod) (*Watcher, error)

Watch watches a set of include and exclude patterns relative to a given root.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop watching, and close the channel passed to Watch.

Directories

Path Synopsis
cmd
test command

Jump to

Keyboard shortcuts

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