romanoff / fsmonitor

Fsmonitor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fsmonit

Simple wrapper around fsnotify to monitor changes in files and folders (including subdirectories created after monitoring has started).

Example:

package main

import (
	"github.com/romanoff/fsmonitor"
	"fmt"
	"log"
	)
func main() {
	watcher, err := fsmonitor.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	err = watcher.Watch("/tmp/foo")
	if err != nil {
		log.Fatal(err)
	}
	for {
		select {
		case ev := <-watcher.Event:
			fmt.Println("event:", ev)
		case err := <-watcher.Error:
			fmt.Println("error:", err)
		}
	}
}

There is also an option to skip certain folders (like .git for example):

	watcher, err := fsmonitor.NewWatcherWithSkipFolders([]string{".git"})

About

Fsmonitor

License:MIT License


Languages

Language:Go 100.0%