Help us shape the future of Go! Take the 2026 Go Developer Survey

watcher

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.2.3

type Event struct {
	Kind EventKind // what happened
	Name string    // file or folder name involved
	Dest string    // for KindOrganized: the destination; otherwise empty
	Err  error     // set when Kind is KindError
}

Event is a single piece of activity reported by Watcher.Start.

type EventKind added in v0.2.3

type EventKind int

EventKind identifies the type of activity reported to the watch output.

const (
	KindOrganized EventKind = 0 // a file was organized into a compartment
	KindCreated   EventKind = 1 // a new user folder appeared
	KindDeleted   EventKind = 2 // a user folder was deleted or renamed away
	KindError     EventKind = 3 // watcher or processing error
)

type WatchOptions

type WatchOptions struct {
	Directory  string
	Preset     string
	Rules      []string
	Name       string
	Debounce   time.Duration
	Initial    bool
	DryRun     bool
	DateSource string
	// EnrichFunc optionally enriches a scanned file with sample-based
	// metadata (format sniffing, embedded dates, extra fields) before it is
	// planned. When nil, files are planned with the built-in metadata only.
	// The second return value reports whether the file was modified so the
	// planner can skip re-planning untouched files.
	EnrichFunc func(file models.File) (models.File, bool)
	// PluginRules are custom rules contributed by installed classifier
	// plugins; the shared resolver layers them in last.
	PluginRules []models.Rule
	// ClassifyFunc overrides category classification of incoming files (the
	// composite built-in + plugin classifier). When nil, the built-in
	// extension classifier is used.
	ClassifyFunc func(filename, ext string) string
}

WatchOptions configures watch mode

type Watcher

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

Watcher monitors a folder and sorts incoming files

func New

func New(opts WatchOptions) (*Watcher, error)

New creates a Watcher

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context, cb func(ev Event)) error

Start begins watching the target folder

Jump to

Keyboard shortcuts

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