Documentation ¶
Overview ¶
watchgod is a very simple compile daemon for Go. watchgod watches your .go files in a directory and invokes `go build` if a file changes. Examples In its simplest form, the defaults will do. With the current working directory set to the source directory you can simply…
$ watchgod
… and it will recompile your code whenever you save a source file. If you want it to also run your program each time it builds you might add…
$ watchgod -command="./MyProgram -my-options"
… and it will also keep a copy of your program running. Killing the old one and starting a new one each time you build. For advanced usage you can also supply the changed file to the command by doing…
$ watchgod -command="./MyProgram -my-options %[1]s"
…but note that this will not be set on the first start. You may find that you need to exclude some directories and files from monitoring, such as a .git repository or emacs temporary files…
$ watchgod -exclude-dir=.git -exclude=".#*"
If you want to monitor files other than .go and .c files you might…
$ watchgod -include=Makefile -include="*.less" -include="*.tmpl"
Options There are command line options.
FILE SELECTION -directory=XXX – Which directory to monitor for changes -recursive=XXX – Look into subdirectories -exclude-dir=XXX – Exclude directories matching glob pattern XXX -exlude=XXX – Exclude files whose basename matches glob pattern XXX -include=XXX – Include files whose basename matches glob pattern XXX -pattern=XXX – Include files whose path matches regexp XXX MISC -log-prefix - Enable/disable stdout/stderr labelling for the child process -graceful-kill - On supported platforms, send the child process a SIGTERM to allow it to exit gracefully if possible. -graceful-timeout - Duration (in seconds) to wait for graceful kill to complete -verbose - Print information about watched directories. ACTIONS -build=CCC – Execute CCC to rebuild when a file changes -command=CCC – Run command CCC after a successful build, stops previous command first