-
-
Save anonymous/0be98b914aa840192662fb087a92c497 to your computer and use it in GitHub Desktop.
Install go from src. Usage bin/install-go <version>
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 | |
set -ex | |
TMP_DIR=`pwd`/tmp | |
BUILD_DIR=$TMP_DIR/build | |
BUILD_GO_DST=$HOME/opt/lang/go1.4 | |
FINAL_GO_DST=$HOME/opt/lang/go$1 | |
rm -rf $TMP_DIR | |
mkdir -p $TMP_DIR && cd $TMP_DIR | |
curl -O https://storage.googleapis.com/golang/go1.4-bootstrap-20161024.tar.gz | |
tar xzvf go1.4-bootstrap-20161024.tar.gz | |
cd $TMP_DIR/go/src | |
GOROOT_FINAL=$BUILD_GO_DST ./make.bash | |
cd $TMP_DIR | |
rm -rf $BUILD_GO_DST | |
mv $TMP_DIR/go $BUILD_GO_DST | |
rm -rf $BUILD_DIR | |
mkdir -p $BUILD_DIR/go/$1 | |
cd $BUILD_DIR/go/$1 | |
git clone -b go$1 --single-branch --depth 1 https://go.googlesource.com/go | |
cd $BUILD_DIR/go/$1/src | |
GOROOT_FINAL=$FINAL_GO_DST \ | |
GOROOT_BOOTSTRAP=$BUILD_GO_DST \ | |
./make.bash | |
rm -rf $FINAL_GO_DST | |
mkdir -p $FINAL_GO_DST | |
cd $BUILD_DIR/go/$1 | |
find . -not -path '*/\.*' | cpio -pdum $BUILD_GO_DST | |
rm -rf $BUILD_DIR | |
rm -f $HOME/opt/lang/go | |
ln -nfs $HOME/opt/lang/go{$1/,} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment