A couple of weeks ago I released Watchgopher, a tool that lets you watch directories, listen to file events and react to them.
It’s a simple server written in Go that dispatches file events to pre-configured commands, which can be anything you want them to be: a simple bash script, a small program written in Ruby or a large application written in C. All that’s necessary is for the command to react to two command line arguments which Watchgopher will hand over to them.
The use-cases are numerous and diverse: managing large file collections, backing up files, archiving GIFs, running tests, compiling and building projects and much more.
The goal when building Watchgopher was for it to be as simple and portable as possible and also for me to get to know the Go programming language better. That resulted in a small and easy to comprehend code base, making its source an ideal read if you want to learn Go.
If you’re interested in using Watchgopher and how to use it: I wrote a lengthy blogpost about Watchgopher and how to use it.
Since writing that blog post a couple of features have been added to Watchgopher, including the ability to log the output of the command and to change its working directory, making it even more versatile.
So, have a look at Watchgopher, either for studying the source code and learning about Go’s channels, how to write simple test suites in Go or to find configuration options. Any feedback is welcome!