Last active
May 8, 2024 12:23
-
-
Save ashemedai/21b2e22b01d1257ddb1de2a540922e9c to your computer and use it in GitHub Desktop.
go fetch and install script
This file contains 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 | |
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