watchfiles

package module
v0.0.0-...-08b6a08 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

README

go-watchfiles

Utility to watch a file, or a directory, and get notified when the file(s) are changed, deleted, or added.

Documentation

Overview

Package watchfiles provides a reusable utility to watch files and get notified of changes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLog

func SetLog(l *log.Logger)

SetLog allows customizing the logger

Types

type RemoveCallback

type RemoveCallback func(filePath string)

RemoveCallback gets invoked when a watched file is modified

type UpdateCallback

type UpdateCallback func(filePath string, reader *bufio.Reader)

UpdateCallback gets invoked when a watched file is modified, or when a new file is added to a watched directory

type WatchFiles

type WatchFiles struct {
	// contains filtered or unexported fields
}

WatchFiles allows loading, and optionally watching files for changes.

func NewWatchFiles

func NewWatchFiles(filePath string, filePattern *regexp.Regexp, updateCb UpdateCallback,
	removeCb RemoveCallback) (*WatchFiles, error)

NewWatchFiles is the constructor function for a Config instance

The following parameters are supported:
	filePath: the directory or file to open and watch. If a directory is used, all files in it are loaded
	updateCb: (optional) a callback that is invoked when config data files are updated, or added
	removeCb: (optional) a callback that is invoked when config data files are removed

func (*WatchFiles) StartWatch

func (wf *WatchFiles) StartWatch() error

StartWatch loads and watches files

func (*WatchFiles) StopWatch

func (wf *WatchFiles) StopWatch()

StopWatch stops watching files

Jump to

Keyboard shortcuts

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