Version: v1.0.2 Latest Latest

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

Go to latest
Published: Aug 10, 2017 License: BSD-3-Clause Imports: 10 Imported by: 0


watcher command


go get -u


Usage of watcher:
  -cmd string
    	command to run when an event occurs
    	watch dot files (default true)
  -interval string
    	watcher poll interval (default "100ms")
    	keep alive when a cmd returns code != 0
    	list watched files on start
    	pipe event's info to command's stdin
    	watch folders recursively (default true)
    	run the command when watcher starts

All of the flags are optional and watcher can be simply called by itself:


(watches the current directory recursively for changes and notifies for any events that occur.)

A more elaborate example using the watcher command:

watcher -dotfiles=false -recursive=false -cmd="./myscript" main.go ../

In this example, watcher will ignore dot files and folders and won't watch any of the specified folders recursively. It will also run the script ./myscript anytime an event occurs while watching main.go or any files or folders in the previous directory (../).

Using the pipe and cmd flags together will send the event's info to the command's stdin when changes are detected.

First create a file called with the following contents:

import sys

for line in sys.stdin:
	print (line + " - python")

Next, start watcher with the pipe and cmd flags enabled:

watcher -cmd="python" -pipe=true

Now when changes are detected, the event's info will be output from the running python script.


The Go Gopher

There is no documentation for this package.

Source Files

Jump to

Keyboard shortcuts

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