Skip to content
/ rnotify Public

`rnotify` is a wrapper of `fsnotify`, supports recursive directory watching on Go.

License

Notifications You must be signed in to change notification settings

y-yagi/rnotify

Repository files navigation

rnotify

Build Status Go Reference

rnotify is a wrapper of fsnotify, supports recursive directory watching on Go.

Supported Platforms

Linux, Windows and macOS.

Usage

package main

import (
	"log"

	"github.com/fsnotify/fsnotify"
	"github.com/y-yagi/rnotify"
)

func main() {
	watcher, err := rnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()

	done := make(chan bool)

	go func() {
		for {
			select {
			case event, ok := <-watcher.Events:
				if !ok {
					return
				}
				log.Println("event:", event)
				// `Op` is the same as `fsnotify.Op`.
				if event.Op&fsnotify.Write == fsnotify.Write {
					log.Println("modified file:", event.Name)
				}
			case err, ok := <-watcher.Errors:
				if !ok {
					return
				}
				log.Println("error:", err)
			}
		}
	}()

	err = watcher.Add("/tmp/foo")
	if err != nil {
		log.Fatal(err)
	}

	<-done
}

About

`rnotify` is a wrapper of `fsnotify`, supports recursive directory watching on Go.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy