Created
February 13, 2017 15:48
-
-
Save fuzzy/567e59ee2c014ec457cc629c3e9f31b8 to your computer and use it in GitHub Desktop.
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
# Uncomment this for debugging output | |
#set -x | |
test ! -z "$(which clang 2>/dev/null)" && CC=clang || CC=gcc | |
GOOS=$(uname -s) | |
GOARCH=$(uname -m) | |
GOBASE=${HOME}/.goroot/${GOOS}/${GOARCH} | |
GOVERS_BSTRAP=1.4.3 | |
GOFILE_BSTRAP=${HOME}/.goroot/go${GOVERS_BSTRAP}.src.tar.gz | |
GOURL_BSTRAP=https://storage.googleapis.com/golang/go${GOVERS_BSTRAP}.src.tar.gz | |
GOVERS_ACTIVE=1.7.3 | |
GOFILE_ACTIVE=${HOME}/.goroot/go${GOVERS_ACTIVE}.src.tar.gz | |
GOURL_ACTIVE=https://storage.googleapis.com/golang/go${GOVERS_ACTIVE}.src.tar.gz | |
test ! -d ${GOBASE} && mkdir -p ${GOBASE} | |
# if we don't have our bootstrap version | |
cd ${GOBASE} | |
if test ! -e ${PWD}/bootstrap/bin/go; then | |
test ! -e ${GOFILE_BSTRAP} && wget -c ${GOURL_BSTRAP} -O ${GOFILE_BSTRAP} | |
tar -zxf ${GOFILE_BSTRAP} && mv go bootstrap | |
cd ${GOBASE}/bootstrap/src && env CC=${CC} ./make.bash | |
fi | |
# and if we don't have our specified active version | |
cd ${GOBASE} | |
if test ! -e ${PWD}/${GOVERS_ACTIVE}/bin/go; then | |
test ! -e ${GOFILE_ACTIVE} && wget -c ${GOURL_ACTIVE} -O ${GOFILE_ACTIVE} | |
tar -zxf ${GOFILE_ACTIVE} && mv go ${GOVERS_ACTIVE} | |
rm -f active && ln -s ${GOVERS_ACTIVE} active | |
cd ${GOBASE}/${GOVERS_ACTIVE}/src && env CC=${CC} GOROOT_BOOTSTRAP=${GOBASE}/bootstrap ./make.bash | |
fi | |
cd ${HOME} | |
# This hurts nothing to stay uncommented | |
set +x | |
export GOROOT=${GOBASE}/active | |
export GOPATH=${HOME}/.gopath/$(uname -s)/$(uname -m) | |
test -z "$(echo $PATH|grep ${GOROOT}/bin) 2>/dev/null" || export PATH=${GOROOT}/bin:${PATH} | |
test -z "$(echo $PATH|grep ${GOPATH}/bin) 2>/dev/null" || export PATH=${GOPATH}/bin:${PATH} | |
test ! -d ${GOPATH} && mkdir -p ${GOPATH} | |
for d in src pkg; do | |
test ! -d ${HOME}/.gopath/${d} && mkdir -p ${HOME}/.gopath/${d} | |
test ! -L ${GOPATH}/${d} && ln -s ${HOME}/.gopath/${d} ${GOPATH}/${d} | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment