Skip to content

Instantly share code, notes, and snippets.

@huglester
Forked from c29r3/install_golang.sh
Last active January 12, 2021 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huglester/09b01d47ee7bfd01667cc4391c3a4bce to your computer and use it in GitHub Desktop.
Save huglester/09b01d47ee7bfd01667cc4391c3a4bce to your computer and use it in GitHub Desktop.
#!/bin/bash
GO_VERSION=${GO_VERSION:=1.15.2}
cd /tmp/ \
&& wget -q https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz \
&& rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go*.tar.gz \
&& rm go$GO_VERSION*.gz
echo "Creating default Go folders"
mkdir -p $HOME/go/bin
if [[ -z "${GOROOT}" ]]; then
echo "GOROOT is undefined --> creating defaut env variables"
echo -e '\nexport PATH=$HOME/go/bin:$PATH
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=auto
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> $HOME/.profile;
source $HOME/.profile
else
echo "GOROOT env is alredy exists: $GOROOT"
fi
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment