fsmonitor

package module
v0.0.0-...-6562058 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: MIT Imports: 3 Imported by: 2

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	Event       chan fsnotify.Event
	Error       chan error
	SkipFolders []string
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher() (*Watcher, error)

func NewWatcherWithSkipFolders

func NewWatcherWithSkipFolders(skipFolders []string) (*Watcher, error)

func (*Watcher) Watch

func (self *Watcher) Watch(path string) error

Jump to

Keyboard shortcuts

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