Skip to content
This repository has been archived by the owner on Jan 14, 2022. It is now read-only.

nathany/vagrant-gopher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.