Last active
October 27, 2016 17:49
-
-
Save fuzzy/b3f4e1a7e72bcfc7157214fff06a7b68 to your computer and use it in GitHub Desktop.
Added this to my ~/.profile.d/ which is helpful as I nfs mount my home directory across several machines, not all running Linux, and not all on the same architecture. under $GOPATH src and pkg are shared dirs with each bin dir being arch/platform specific.
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 | |
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 && ./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 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|grep -v grep)" || export PATH=${GOROOT}/bin:${PATH} | |
test -z "$(echo $PATH|grep ${GOPATH}/bin|grep -v grep)" || 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