Bash script to automate installation and removal of single user Go language tools.
Feel free to change the variables on the beginning to match whatever version of Go you need.
Works for:
- ✅ Ubuntu 16.04 and above
- ✅ macOS Sierra and above
wget
orcurl
- Bash shell
Download and run with wget
or curl
:
# Linux typically has wget installed
wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
# macOS typically has curl installed
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
Pass the --version
option into the script including the version that you wish to install. This specify a different version without needing to change the variable in the script.
wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh \
| bash -s -- --version 1.13.2
# or...
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh \
| bash -s -- --version 1.13.2
Pass the --remove
option into the script:
wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh \
| bash -s -- --remove
# or...
curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh \
| bash -s -- --remove
By default the script will create .go
and go
folders on your home directory, add the needed variables and PATH
expansion.
$HOME/.go is the directory where Go will be installed to.
$HOME/go is the default workspace directory.
Read more about the workspace.
In order to install Go into another location, set the environment variables $GOROOT
and $GOPATH
before (un)installing:
export GOROOT=/opt/go
export GOPATH=$HOME/projects/go