watcher

package
v0.0.0-...-5a1941a Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2016 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package watcher is used for watching files and directories for automatic recompilation and restart of app on change when in development mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

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

Type is a watcher type that allows registering new pattern - actions pairs.

func NewType

func NewType() *Type

NewType allocates and returns a new instance of watcher Type.

func (*Type) Listen

func (t *Type) Listen(pattern string, fn func()) *fsnotify.Watcher

Listen gets a pattern and a function. The function will be executed when files matching the pattern will be modified.

func (*Type) ListenFile

func (t *Type) ListenFile(path string, fn func()) *fsnotify.Watcher

ListenFile is equivalent of Listen but for files. If file is added using ListenFile and the same file is within a pattern of Listen, only the first one will trigger restarts. I.e. we have the following calls:

w.Listen("./", fn1)
w.ListenFile("./goal.yml", fn2)

If "goal.yml" file is modified fn2 will be triggered. fn1 may be triggered by changes in any file inside "./" directory except "goal.yml".

func (*Type) NotifyOnUpdate

func (t *Type) NotifyOnUpdate(pattern string, watcher *fsnotify.Watcher, fn func())

NotifyOnUpdate starts the function every time a file change event is received. Start it as a goroutine.

Jump to

Keyboard shortcuts

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