Skip to content

Instantly share code, notes, and snippets.

@ashemedai
Last active May 8, 2024 12:23
Show Gist options
  • Save ashemedai/21b2e22b01d1257ddb1de2a540922e9c to your computer and use it in GitHub Desktop.
Save ashemedai/21b2e22b01d1257ddb1de2a540922e9c to your computer and use it in GitHub Desktop.
go fetch and install script
#!/bin/sh
if [ -z ${1} ]; then
echo "Enter go release number"
read VERSION
else
VERSION=${1}
fi
ARCHIVE="go${VERSION}.linux-amd64.tar.gz"
URL="https://go.dev/dl/${ARCHIVE}"
INSTALL_HOME="${HOME}/.local"
fetch () {
echo "Fetching archive from '${URL}'"
curl -sSLO "${URL}"
}
extract () {
rm -rf "${INSTALL_HOME}/go"
tar -x -f "${ARCHIVE}" -C "${INSTALL_HOME}" -v -z
}
if [ -f "${ARCHIVE}" ]; then
extract
else
fetch
extract
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment