Skip to content

Instantly share code, notes, and snippets.

@jpillora
Last active July 28, 2022 06:38
Show Gist options
  • Save jpillora/dcabf16e99d087eae6e0 to your computer and use it in GitHub Desktop.
Save jpillora/dcabf16e99d087eae6e0 to your computer and use it in GitHub Desktop.
Install latest version of Go in Linux
#!/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
Copy link

ghost commented Nov 29, 2020

Not working unfortunately ^^

 ./install-golang.sh
Fetching latest Go version...
Installing 'go1.1.linux-amd64'...
##################################################################################################################################################################################################### 100.0%

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment