Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active February 12, 2020 21:55
Show Gist options
  • Save selfup/c4acad07c59d2636e7b55b153694a845 to your computer and use it in GitHub Desktop.
Save selfup/c4acad07c59d2636e7b55b153694a845 to your computer and use it in GitHub Desktop.
Install Go Linux

⚠️

Please read aa_install_go_linux.sh prior to running this

curl \
https://gist.githubusercontent.com/selfup/c4acad07c59d2636e7b55b153694a845/raw/45081fd0fa8cca546f908c429514d59139fe42e9/install_go_linux.sh \
| bash
#!/usr/bin/env bash
###
# Please Read the License at the end of this file
###
: '
WARNING THINGS WILL BE DELETED: $HOME/go AND/OR /usr/local/go
sudo WILL ONLY BE REQUIRED IF YOU ALREADY HAVE GO IN /usr/local/go
GOLANG WILL BE INSTALLED IN YOUR HOME DIR: $HOME/go
GOROOT WILL BE: $HOME/go
GOPATH WILL BE $HOME/golang
THIS INSTALL SCRIPT IS FOR DEV MACHINES NOT PRODUCTION OR CRONJOB/SCHEDULED JOB RELATED MACHINES
'
set -e
if [[ -d $HOME/go ]]; then rm -rf $HOME/go; fi
if [[ -d /usr/local/go ]]; then rm -rf /usr/local/go; fi
GO_DL_VERSION=go1.13.7
wget https://dl.google.com/go/$GO_DL_VERSION.linux-amd64.tar.gz
tar -C $HOME -xzf $GO_DL_VERSION.linux-amd64.tar.gz
mkdir -p $HOME/golang/src/github.com
mkdir -p $HOME/golang/src/gitlab.com
mkdir -p $HOME/golang/src/bitbucket.org
touch $HOME/.bashrc
GO_ROOT_SET=$(cat $HOME/.bashrc | grep -q 'GOROOT=$HOME/go' || 1)
GO_PATH_SET=$(cat $HOME/.bashrc | grep -q 'GOPATH=$HOME/golang' || 1)
PATH_GO_SET=$(cat $HOME/.bashrc | grep -q 'PATH=$PATH:$GOROOT/bin:$GOPATH/bin' || 1)
if [[ $GO_ROOT_SET -eq 1 ]]; then echo 'export GOROOT=$HOME/go' >> $HOME/.bashrc; fi
if [[ $GO_PATH_SET -eq 1 ]]; then echo 'export GOPATH=$HOME/golang' >> ~/.bashrc; fi
if [[ $PATH_GO_SET -eq 1 ]]; then echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc; fi
source $HOME/.bashrc
go version
rm $GO_DL_VERSION.linux-amd64.tar.gz
: '
The MIT License
Copyright (c) 2019-2020 Regis Boudinot (selfup) https://selfup.me
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment