|
|
|
@ -9,7 +9,6 @@ PREFIX_DIR=/usr/local
|
|
|
|
|
|
|
|
|
|
GO_PREFIX_DIR=${PREFIX_DIR}/golang
|
|
|
|
|
GO_DEST_DIR=${GO_PREFIX_DIR}/${GO_VERSION}
|
|
|
|
|
GO_CURRENT=${PREFIX_DIR}/go
|
|
|
|
|
|
|
|
|
|
OS=
|
|
|
|
|
if [[ $OSTYPE =~ linux ]]; then
|
|
|
|
@ -17,7 +16,7 @@ if [[ $OSTYPE =~ linux ]]; then
|
|
|
|
|
elif [[ $OSTYPE =~ darwin ]]; then
|
|
|
|
|
OS=darwin
|
|
|
|
|
else
|
|
|
|
|
echo unknown os: $OSTYPE
|
|
|
|
|
echo unknown os: "$OSTYPE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
@ -25,36 +24,36 @@ ARCH=
|
|
|
|
|
if [[ $(uname -m) == x86_64 ]]; then
|
|
|
|
|
ARCH=amd64
|
|
|
|
|
else
|
|
|
|
|
echo arch not yet supported: $(uname -m)
|
|
|
|
|
echo arch not yet supported: "$(uname -m)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[[ -d ${GO_DEST_DIR} ]] || sudo mkdir -p ${GO_DEST_DIR}
|
|
|
|
|
[[ -d ${GO_DEST_DIR} ]] || sudo mkdir -p "${GO_DEST_DIR}"
|
|
|
|
|
|
|
|
|
|
TMP_DIR=
|
|
|
|
|
if [[ ! -d ${GO_DEST_DIR}/bin ]]; then
|
|
|
|
|
TMP_DIR=$(mktemp --directory)
|
|
|
|
|
DEST_FILE=$TMP_DIR/go.tar.gz
|
|
|
|
|
URL=https://dl.google.com/go/go${GO_VERSION}.${OS}-${ARCH}.tar.gz
|
|
|
|
|
echo downloading go $GO_VERSION to temp directory ${TMP_DIR}
|
|
|
|
|
curl --silent --output ${DEST_FILE} ${URL}
|
|
|
|
|
echo downloading go "$GO_VERSION" to temp directory "${TMP_DIR}"
|
|
|
|
|
curl --silent --output "${DEST_FILE}" "${URL}"
|
|
|
|
|
|
|
|
|
|
sudo tar xf ${DEST_FILE} --directory ${GO_DEST_DIR} --strip-components 1
|
|
|
|
|
sudo chown --recursive root:root ${GO_DEST_DIR}
|
|
|
|
|
sudo tar xf "${DEST_FILE}" --directory "${GO_DEST_DIR}" --strip-components 1
|
|
|
|
|
sudo chown --recursive root:root "${GO_DEST_DIR}"
|
|
|
|
|
else
|
|
|
|
|
echo go $GO_VERSION already installed
|
|
|
|
|
echo go "$GO_VERSION" already installed
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd ${PREFIX_DIR}
|
|
|
|
|
[[ -s go ]] && sudo unlink go
|
|
|
|
|
sudo ln --symbolic ${GO_DEST_DIR} go
|
|
|
|
|
echo current version set to ${GO_VERSION}
|
|
|
|
|
sudo ln --symbolic "${GO_DEST_DIR}" go
|
|
|
|
|
echo current version set to "${GO_VERSION}"
|
|
|
|
|
|
|
|
|
|
[[ -f /etc/profile.d/go-path.sh ]] \
|
|
|
|
|
|| echo 'export PATH=$PATH:/usr/local/go/bin' \
|
|
|
|
|
|| echo "export PATH=\$PATH:/usr/local/go/bin" \
|
|
|
|
|
| sudo tee /etc/profile.d/go-path.sh
|
|
|
|
|
|
|
|
|
|
if [[ $TMP_DIR != "" ]]; then
|
|
|
|
|
rm -rf ${TMP_DIR}
|
|
|
|
|
echo removed up temp directory ${TMP_DIR}
|
|
|
|
|
rm -rf "${TMP_DIR}"
|
|
|
|
|
echo removed up temp directory "${TMP_DIR}"
|
|
|
|
|
fi
|
|
|
|
|