Skip to content

Instantly share code, notes, and snippets.

@philcryer
Last active August 29, 2015 13:58
Show Gist options
  • Save philcryer/9960262 to your computer and use it in GitHub Desktop.
Save philcryer/9960262 to your computer and use it in GitHub Desktop.
I installed Go (golang) in Ubuntu 13.10, but the available package currently installs version 1.1.2, while I need at least 1.2 for a project. Online HOWTOs were weak, and or outdated, but I found this script online. I fixed some errors in it and then posted it here to share. As always, read the script to understand what it does before you run it…
#!/bin/bash
# Save the pwd
cwd=`pwd`
# Set the env
cat >> ~/.profile << EOT
export GOROOT=$HOME/go
export GOOS=linux
#export GOARCH=`arch`
#NOTE: last line errors with: go tool dist: unknown $GOARCH x86_64 - hard-coding for great justice!
export GOARCH=amd64
export GOBIN=$HOME/bin
EOT
# Set the Path
cat >> ~/.bashrc << EOT
export PATH=${PATH}:$GOBIN
EOT
# Source them
source ~/.profile
source ~/.bashrc
# Build deps
sudo apt-get install python-setuptools python-dev build-essential mercurial bison gcc libc6-dev ed make
# Check out the source
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
# Build the source
cd $GOROOT/src ; ./all.bash
# Get back
cd $cwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment