nathany / vagrant-gopher

A Vagrantfile for running Go VMs

Home Page:https://nathany.com/go-testing-toolbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vagrant Gopher

A Vagrantfile for running Go VMs (Linux, BSD and Solaris). While cross-compilation works great in Go, having actual VMs can be useful to run tests or debug programs under other operating systems.

Requirements

Vagrant, VirtualBox and a Go workspace.

On a Mac, you can use Homebrew Cask to install:

brew cask install virtualbox vagrant

Usage

Copy this Vagrantfile to $GOPATH/src/Vagrantfile:

src:~$ curl -O https://raw.githubusercontent.com/nathany/vagrant-gopher/master/Vagrantfile

Then run vagrant up from any subfolder.

This will mount your src folder as a shared folder inside the VMs, while creating new bin/pkg folders to avoid collisions (particularly bin).

Use vagrant ssh linux, vagrant ssh bsd, or vagrant ssh solaris to login and look around, or run a single command like vagrant ssh linux -c 'go version'.

You will likely need to change directories. CDPATH is configured for GitHub to save a few keystrokes, e.g.

vagrant ssh linux -c 'cd fsnotify/fsnotify; go test ./... -race'

Use vagrant halt to shutdown or vagrant destroy to free up disk space.

See the Vagrant Command Line documentation for details.

Notes

  • Currently this shares the src/ folder into $HOME/src on the virtual machine ($HOME/go/src did 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.

About

A Vagrantfile for running Go VMs

https://nathany.com/go-testing-toolbox/

License:BSD 2-Clause "Simplified" License