Created
June 20, 2015 16:25
-
-
Save fuzzy/c58c435ab3771643103c to your computer and use it in GitHub Desktop.
bootstrap-go.sh
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/sh | |
unset GOROOT | |
unset GOPATH | |
GOBASE=${HOME}/.govers/$(uname -s)/$(uname -m) | |
GO_SVER=${1:-"1.4.2"} | |
go14src=https://storage.googleapis.com/golang/go${GO_SVER}.src.tar.gz | |
go14fnm=$(basename ${go14src}) | |
if test ! -d ${GOBASE}/${GO_SVER}; then | |
mkdir -p ${GOBASE}/${GO_SVER} | |
cd ${GOBASE}/${GO_SVER} && wget -c ${go14src} && tar zxf ${go14fnm} | |
mv go goroot && cd ${GOBASE}/${GO_SVER}/goroot/src && ./make.bash | |
fi | |
if test ! -d ${GOBASE}/head && test ! -z "$(echo ${GO_SVER}|grep 1.4)"; then | |
mkdir -p ${GOBASE}/head | |
cd ${GOBASE}/head && git clone https://github.com/golang/go.git goroot | |
GOBOOT=${GOBASE}/${GO_SVER}/goroot | |
cd ${GOBASE}/head/goroot/src && env GOROOT_BOOTSTRAP=${GOBOOT} ./make.bash || exit 1 | |
fi | |
echo "You will want to add the following to your ~/.(profile|bashrc|whatever)" | |
echo "assuming you have not already done so." | |
echo | |
echo "export GOBASE=\${HOME}/.govers/\$(uname -s)/\$(uname -m)" | |
echo "export BASEPATH=\${PATH}" | |
echo | |
cat <<EOF | |
gosel() { | |
case "\${1}" in | |
(select) | |
if test -d \${GOBASE}/\${2}; then | |
export GOROOT=\${GOBASE}/\${2}/goroot | |
export GOPATH=\${GOBASE}/\${2}/gopath | |
export PATH=\${GOROOT}/bin:\${GOPATH}/bin:\${BASEPATH} | |
test ! -d \${GOPATH} && mkdir -p \${GOPATH} | |
fi | |
;; | |
(list) ls \${GOBASE}/ ;; | |
esac | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment