rfsnotify

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2023 License: MIT Imports: 5 Imported by: 1

README

rfsnotify

A wrapper of golang fsnotify that automatically recursively watches directory

Usage

package main

import (
	"log"

	"github.com/dasbd72/rfsnotify"
)

func main() {
    watcher, err := rfsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	err = watcher.Add(root_dir)
	if err != nil {
		log.Fatal(err)
	}

    for {
		select {
		case ev := <-watcher.Events:
			log.Println("event:", ev)
		case err := <-watcher.Errors:
			log.Println("error:", err)
		}
		log.Println(watcher.WatchList())
	}
}

Documentation

Index

Constants

Variables

View Source
var (
	ErrNonExistentWatch = fsnotify.ErrNonExistentWatch
	ErrEventOverflow    = fsnotify.ErrEventOverflow
)

Common errors that can be reported by a watcher

Functions

This section is empty.

Types

type Event

type Event = fsnotify.Event

type Op

type Op = fsnotify.Op

type Watcher

type Watcher struct {
	Events chan fsnotify.Event

	// Errors sends any errors.
	Errors chan error
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher() (*Watcher, error)

func (*Watcher) Add

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

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

func (*Watcher) WatchList

func (w *Watcher) WatchList() []string

Jump to

Keyboard shortcuts

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