Skip to content

Latest commit

 

History

History
39 lines (35 loc) · 788 Bytes

README.md

File metadata and controls

39 lines (35 loc) · 788 Bytes

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"})