A Vagrantfile for running Go VMs (Linux and BSD). While cross-compilation works great in Go, having actual VMs can be useful to run tests or debug programs under other operating systems.
Copy this Vagrantfile to src/Vagrantfile:
src:~$ curl -O https://raw.githubusercontent.com/nathany/vagrant-gopher/master/Vagrantfile
vagrant up from any subfolder.
This will mount your src folder as a shared folder inside the Linux/BSD VMs, while creating new bin/pkg folders to avoid collisions (particularly bin).
vagrant ssh linux or
vagrant ssh bsd to login and look around, or run a single command like
vagrant ssh linux -c 'go help'.
You will likely need to change directories. CDPATH is configured for the major source code hosts to save a few keystrokes, eg.
vagrant ssh linux -c 'cd nathany/looper; go test ./...'
vagrant halt to shutdown or
vagrant destroy to free up disk space.
See the Vagrant Command Line documentation for details.
- Currently this shares the src/ folder into
$HOME/srcon the virtual machine (
$HOME/go/srcdid not work).
- It would be nice to have a wrapper/plugin around the ssh command that runs commands based on the current folder.
- Shared folders aren't compatible with tools that watch files inside the VM using fsnotify.
- 64-bit boxes are used to support the Go race detector.
- The BSD box does not support Windows hosts.