Last active
August 29, 2015 14:08
-
-
Save ambakshi/d37a89b25d4354ace0ab to your computer and use it in GitHub Desktop.
Install the latest version of golang and some useful tools from source into ~/opt/go1.x
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# 1. Downloads, builds and install Golang from source. | |
# into $HOME/opt/goXXX where GOROOT is $HOME/opt/go | |
# symlink to the current version. | |
# 2. Install some standard go tools and helpers | |
# 3. Update $GOPATH built packages with new version of compiler | |
# | |
set -e | |
# 1. Download and extract go source into ~/opt/goXXX | |
V=${1:-1.4} | |
GOROOT="${GOROOT:-$HOME/opt/go}" | |
mkdir -p $(dirname $GOROOT) # mkdir ~/opt1 | |
cd $(dirname $GOROOT) # cd ~/opt | |
mkdir -p go${V} # mkdir ~/opt/go1.4 | |
ln -sfn $PWD/go${V} $GOROOT # ln ~/opt/go -> ~/opt/go1.4 | |
# The files in the tar are already in a go/ subdirectory | |
curl -fsSL https://storage.googleapis.com/golang/go${V}.src.tar.gz | tar zxf - | |
cd $GOROOT/src | |
# Build go toolchain for the target we need | |
for GOOS in darwin linux; do | |
for GOARCH in amd64; do | |
GOOS=$GOOS GOARCH=$GOARCH ./make.bash --no-clean | |
done | |
done | |
# 2. Install some standard go tools and helpers | |
TOOLS=( | |
golang.org/x/tools/cmd/benchcmp | |
golang.org/x/tools/cmd/cover | |
golang.org/x/tools/cmd/eg | |
golang.org/x/tools/cmd/godex | |
golang.org/x/tools/cmd/godoc | |
golang.org/x/tools/cmd/goimports | |
golang.org/x/tools/cmd/gorename | |
golang.org/x/tools/cmd/gotype | |
golang.org/x/tools/cmd/oracle | |
golang.org/x/tools/cmd/present | |
golang.org/x/tools/cmd/ssadump | |
golang.org/x/tools/cmd/vet | |
golang.org/x/tools/cmd/present | |
golang.org/x/tools/cmd/stringer | |
code.google.com/p/rog-go/exp/cmd/godef | |
github.com/golang/lint/golint | |
github.com/kisielk/errcheck | |
github.com/jstemmer/gotags | |
github.com/nsf/gocode | |
github.com/tools/godep | |
github.com/davecheney/gcvis) | |
export GOPATH="${GOPATH:-$HOME/go}" | |
export PATH="$GOROOT/bin:$GOPATH/bin:$PATH" | |
for url in ${TOOLS[@]}; do | |
echo go get $url && go get -u $url | |
done | |
# 3. Update $GOPATH built packages with new version of compiler | |
# go get -u all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment