Quite a few people use Vagrant as their development environment. It provides a nice way to basically package all your dependencies in a neat fashion so that you don’t have to worry too much about installing binaries and versions - no longer do you need to worry about virtualenvs or rvms or how to install a particular database when some of the devs have OSX, others use Linux and some enjoy some brand of Windows. Just say "git clone", "vagrant up" and go. Your editor lives on your regular desktop, and everything else happens inside the Vagrant box.
It’s all good, except for the minor problem known as "filesystem notification events don’t propagate into the Vagrant box" also known as "inotify doesn't work on Linux guest". That means that when you change a file on your host machine, the automatics on the box side don't notice it and don't start a recompile - known as a hot reload - forcing you to recompile manually. There are a couple of ways around this, mostly either by polling actively (which is quite CPU-intensive), or in case of scripting languages like Python, automatically checking the modification dates on each reload. You can also twiddle with vagrant triggers.
However, go (or golang for SEO purposes) is a compiled language, so while there are many hot reload packages, they never see any changes and hence are useless. So imagine my joy when I stumbled upon the vagrant-notify-forwarder Vagrant plugin, which almost automates everything. It installs a daemon on the host side and forwards the filesystem events to the box. You can easily install it with
$ vagrant plugin install vagrant-notify-forwarder $ vagrant reload
However, it only sends ATTRIB changes to the box. And most golang hot reloaders only listen to changes to the actual file content. But the very responsive Ivan Pusic added a nice patch to his excellent rerun utility and suddenly the world works again. Just add the "--attrib" -flag to rerun, doing something like this:
$ vagrant ssh % go get github.com/ivpusic/rerun % cd $GOPATH/src/myproject % rerun --attrib -s *.go
Private comments? Drop me an email. Or complain in a nearby pub - that'll help.
|"Main" last changed on 10-Aug-2015 21:44:03 EEST by JanneJalkanen.|