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