Skip to content

Instantly share code, notes, and snippets.

@chrisvdg
Last active June 2, 2020 07:57
Show Gist options
  • Save chrisvdg/0f25142700cdf6362496c075dc697b8d to your computer and use it in GitHub Desktop.
Save chrisvdg/0f25142700cdf6362496c075dc697b8d to your computer and use it in GitHub Desktop.
Golang installation scripts
#!/bin/bash
GOVersion="1.14.3"
echo "Removing go if already present"
rm -dr /usr/local/go
echo "Downloading Go"
wget -O go.tar.gz https://storage.googleapis.com/golang/go$GOVersion.linux-armv6l.tar.gz
echo "Extracting Go"
sudo tar -C /usr/local -xzf go.tar.gz
# cleanup
echo "Removing Go download file"
rm go.tar.gz
echo "Setting up Go evironment"
mkdir ~/go ~/go/src ~/go/bin ~/go/pkg
echo "Setting up Go environmental variables"
echo "" >> ~/.profile
echo "# golang" >> ~/.profile
echo "export GOPATH=~/go" >> ~/.profile
echo "export GOSRC=~/go/src" >> ~/.profile
echo "export PATH=/usr/local/go/bin:~/go/bin:\$PATH" >> ~/.profile
# source the new exports
source ~/.profile
# test if golang works
go version
echo 'Load the new profile settings by logging out and in again or execute "source ~/.profile"'
#!/bin/bash
GOVersion="1.14.3"
echo "Removing go if already present"
rm -dr /usr/local/go
echo "Downloading Go"
wget -O go.tar.gz https://storage.googleapis.com/golang/go$GOVersion.linux-amd64.tar.gz
echo "Extracting Go"
tar -C /usr/local -xzf go.tar.gz
# cleanup
echo "Removing Go download file"
rm go.tar.gz
echo "Setting up Go evironment"
mkdir ~/go ~/go/src ~/go/bin ~/go/pkg
echo "Setting up Go environmental variables"
echo "" >> ~/.profile
echo "# golang" >> ~/.profile
echo "export GOPATH=~/go" >> ~/.profile
echo "export GOSRC=~/go/src" >> ~/.profile
echo "export PATH=/usr/local/go/bin:~/go/bin:\$PATH" >> ~/.profile
# source the new exports
source ~/.profile
# test if golang works
go version
echo 'Load the new profile settings by logging out and in again or execute "source ~/.profile"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment