Giter VIP home page Giter VIP logo

devbox-golang's Introduction

DevBox-Golong

Vagrant box backed by Docker or Virtualbox, with Ansible provisioning

A Vagrant box (Virtualbox or Docker as providers) with Ansible provisioning for setting up a Vim-based Golang development environment.

Screenshot

Update: Optional build script of latest Go 1.5 with the new cross-compilation support now included!

As blogged by Dave Cheney, cross-compilation to different platforms is now (in the latest Go 1.5 development version) as simple as setting two environment variables and running go build!

To let us laymen test this out easily, we have included an ansible role (aka "build script") for the latest Go 1.5 in this repo. To activate it, just open up the playbook.yml file and uncomment the row - golang-1.5, and instead comment out the line saying - golang, before running vagrant up docker or vagrant up virtualbox.

So, instead of looking like this:

  roles:
	- { role: dotfiles, sudo: false }
    - { role: golang, sudo: false }
   #- { role: golang-1.5, sudo: false }
    - { role: youcompleteme, sudo: false } # Comment out this to save time!!

... it should look like this:

  roles:
	- { role: dotfiles, sudo: false }
   #- { role: golang, sudo: false }
    - { role: golang-1.5, sudo: false }
    - { role: youcompleteme, sudo: false } # Comment out this to save time!!

Note: Please see the "known issues" below though, about messages about failed tests, when building!

(You might also consider commenting out the "YouCompleteMe" step to start with, if you want to play around with this quickly)

Ingredients

Prerequisites

Installing the requirements in Ubuntu (tested with 14.04)

  1. Install Virtualbox:

    sudo apt-get install virtualbox
  2. Install Docker:

    sudo apt-get install docker.io
  3. Install a recent version of ansible:

    sudo apt-get install ansible/trusty-backports

    (if you ubuntu version is "trusty", otherwise, replace it with your appropriate version)

  4. Install Vagrant, by first downloadng the proper .deb file from vagrantup.com

  5. ... and then installing it with:

    sudo dpkg -i <deb-file>

Setup and Usage

Clone the github repository:

git clone [email protected]:samuell/devbox-golang
cd devbox-golang

Bring up the VM

With docker provider (Expect it to take at least ~8m):

vagrant up docker

With VirtualBox provider (Expect it to take at least ~20m):

vagrant up virtualbox

Log in to the VM

With docker provider:

vagrant ssh docker

With VirtualBox provider:

vagrant ssh virtualbox

Create a repository for uploading to github:

mkcd ~/code/go/src/github/<user>/<repo>
git init .

Now, start coding!

vim main.go

A tip on how you can upload your existing git ssh keys to the new vm:

With the following command you can get the info you need to run scp against the machine:

vagrant ssh-config [docker | virtualbox]

Note the hostname and port number (and identity file, if you with), and run, for example:

scp -i <identity-file-path> -P <portno> \
	~/.ssh/id_rsa_<whateveryounamedit> \
	vagrant@<hostname>:/home/vagrant/.ssh/

Then, sometimes, in order to get the new key activated in your shell after logging in to the vm, you might need to do:

ssh-agent bash -l
ssh-add ~/.ssh/id_rsa_<whateveryounamedit>
  • Autocompletion will happen automatically
  • If you have turned off the YouCompleteMe role, you will get autocompletion with <C-x><C-o>

Known issues

  • GDB Breakpoints don't take, unless you follow the advice given here. That is, in short, do this on your Host machine, if you run Ubuntu:

    sudo apt-get install apparmor-utils
    sudo echo 'aa-complain /etc/apparmor.d/docker' >> /etc/rc.local
    sudo aa-complain /etc/apparmor.d/docker

    The problem seems to be that ptrace is not given access to the process otherwise.

  • There are some really red message from the docker daemon when running vagrant halt. Everything seems to work as expected though (including the shutdown)

  • There are some red message on vagrant up, but they are nothing serious, and can be ignored for now.

  • When building Go 1.5 dev, the build will end with a lot of error messages, but that is from the tests after the build. The build itself seems to work, largely.

References

devbox-golang's People

Contributors

jeroenvdgulik avatar samuell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.