Last active
July 28, 2022 06:38
-
-
Save jpillora/dcabf16e99d087eae6e0 to your computer and use it in GitHub Desktop.
Install latest version of Go in Linux
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/bash | |
#force run with bash | |
if [ -z "$BASH_VERSION" ] | |
then | |
exec bash "$0" "$@" | |
return | |
fi | |
#create local scope | |
function install { | |
echo "Fetching latest Go version..." | |
typeset VER=`curl -s https://golang.org/dl/ | grep -m 1 -o 'go1\(\.[0-9]\)\+'` | |
if uname -m | grep 64 > /dev/null; then | |
typeset ARCH=amd64 | |
else | |
typeset ARCH=386 | |
fi | |
typeset FILE=$VER.linux-$ARCH | |
echo "Installing '$FILE'..." | |
curl -# https://storage.googleapis.com/golang/$FILE.tar.gz | | |
tar -C /usr/local -xzf - | |
echo " | |
# Go Paths (Added on: `date -u`) | |
export GOPATH=\$HOME/go | |
export PATH=\$PATH:/usr/local/go/bin:\$GOPATH/bin | |
" >> ~/.bash_profile | |
. ~/.bash_profile | |
echo "Go is installed and your GOPATH is '$HOME/go'" | |
echo "Please reload this shell or enter the command '. ~/.bash_profile'" | |
} | |
install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not working unfortunately ^^