watch

package
v4.10.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

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

Watcher is used to watch a file on a filesystem, and let you do something whenever it's mtime changes.

func New

func New(path string, cb WatcherCallback, pollFrequency time.Duration) (*Watcher, error)

New returns a new Watcher that will call your cb with path's mtime whenever its mtime changes in the future.

It also immediately gets the path's mtime, available via Mtime().

This is intended for use on filesystems that don't support inotify, so the watcher will check for changes to path's mtime every pollFrequency.

func (*Watcher) Mtime

func (w *Watcher) Mtime() time.Time

Mtime returns the latest mtime of our path, captured during New() or the last time we polled.

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop will stop watching our path for changes.

type WatcherCallback

type WatcherCallback func(mtime time.Time)

WatcherCallback, once supplied to New(), will be called each time your Watcher path changes (that is, the file's mtime changes), and is supplied the new mtime of that path.

Jump to

Keyboard shortcuts

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