file-watcher

module
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2019 License: Apache-2.0

README

file-watcher

Get notifications of file change in specified directory. Works on on linux and windows using cgo bindings.

Download

go get github.com/glower/file-watcher

Usage

package main

import (
	"context"
	"log"

	"github.com/glower/file-watcher/notification"
	"github.com/glower/file-watcher/watcher"
)

func main() {
	ctx := context.TODO()

	eventCh, errorCh := watcher.Setup(
		ctx,
		[]string{"/home/igor/Downloads", "C:\\Users\\Igor\\Downloads"},
		[]notification.ActionType{},
		[]string{".crdownload", ".lock", ".snapshot"},
		nil)

	for {
		select {
		case file := <-eventCh:
			log.Printf("[EVENT] %#v", file)
		case err := <-errorCh:
			log.Printf("[%s] %s\n", err.Level, err.Message)
			if err.Level == "CRITICAL" {
				log.Printf("%s\n", err.Stack)
			}
		}
	}
}

Directories

Path Synopsis
hack
cli
Package notifications fixes the problem of multiple file change notifications for the same file from the OS API.
Package notifications fixes the problem of multiple file change notifications for the same file from the OS API.

Jump to

Keyboard shortcuts

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