fsnotify

package
v0.0.0-...-b5c7783 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: BSD-3-Clause, Apache-2.0 Imports: 10 Imported by: 0

README

File system notifications for Go

GoDoc Go Report Card Coverage

fsnotify utilizes golang.org/x/sys rather than syscall from the standard library. Ensure you have the latest version installed by running:

go get -u golang.org/x/sys/...

Cross platform: Windows, Linux, BSD and OS X.

Adapter OS Status
inotify Linux 2.6.27 or later, Android* Supported Build Status
kqueue BSD, OS X, iOS* Supported Build Status
ReadDirectoryChangesW Windows Supported Build status
FSEvents OS X Planned
FEN Solaris 11 In Progress
fanotify Linux 2.6.37+
USN Journals Windows Maybe
Polling All Maybe

* Android and iOS are untested.

Please see the documentation for usage. Consult the Wiki for the FAQ and further information.

API stability

fsnotify is a fork of howeyc/fsnotify with a new API as of v1.0. The API is based on this design document.

All releases are tagged based on Semantic Versioning. Further API changes are planned, and will be tagged with a new major revision number.

Go 1.6 supports dependencies located in the vendor/ folder. Unless you are creating a library, it is recommended that you copy fsnotify into vendor/github.com/fsnotify/fsnotify within your project, and likewise for golang.org/x/sys.

Contributing

Please refer to CONTRIBUTING before opening an issue or pull request.

Example

See example_test.go.

Documentation

Overview

Package fsnotify provides a platform-independent interface for file system notifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name string // Relative path to the file or directory.
	Op   Op     // File operation that triggered the event.
}

Event represents a single file system notification.

func (Event) String

func (e Event) String() string

String returns a string representation of the event in the form "file: REMOVE|WRITE|..."

type Op

type Op uint32

Op describes a set of file operations.

const (
	Create Op = 1 << iota
	Write
	Remove
	Rename
	Chmod
)

These are the generalized file operations that can trigger a notification.

type Watcher

type Watcher struct {
	Events chan Event
	Errors chan error
	// contains filtered or unexported fields
}

Watcher watches a set of files, delivering events to a channel.

func NewWatcher

func NewWatcher() (*Watcher, error)

NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.

func (*Watcher) Add

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

Add starts watching the named file or directory (non-recursively).

func (*Watcher) Close

func (w *Watcher) Close() error

Close removes all watches and closes the events channel.

func (*Watcher) Remove

func (w *Watcher) Remove(name string) error

Remove stops watching the named file or directory (non-recursively).

Jump to

Keyboard shortcuts

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