Installing go toolchain
— Kaushal Modi“Installing” go
is simply extracting its release archive, putting it
somewhere in you $HOME
and pointing GOROOT
and PATH
env vars to
it.
- Add “Updating go” section.
There are two reasons why I suggest installing go
to anyone,
whether they are Go developers, or not (like me).
Installing go
#
Below instructions are for installing go
on a 64-bit GNU/Linux
machine, and using tcsh
shell. But similar steps should work for any
other OS and shell.
- Download the tar.gz for the latest linux-amd64 binaries from https://golang.org/dl/.
- Extract it to some place in your
$HOME
. I extract it to${HOME}/go/
1. - Create a directory where you would want to install the
go
packages.mkdir -p ~/go.apps
- Set the following environment variables2, and also save them to
your shell config:
setenv GOROOT ${HOME}/go # go root setenv GOPATH ${HOME}/go.apps # for go applications
- Add the
${GOROOT}/bin
and${GOPATH}/bin
directories to your$PATH
.
Now you can install any go
application!
For instance, noti
is a nice little utility that triggers an alert
(desktop popup, Pushbullet notification, etc.) when a process
finishes. From its installation notes, you just run the below to
install it:
go get -u github.com/variadico/noti/cmd/noti
Apart from the go
applications I suggested here, go out and explore
more – go get
them 😁
Updating go
#
- Delete the existing
$GOROOT
directory (notGOPATH
!)rm -rf ~/go # as that is my GOROOT
- Download the tar.gz for the latest linux-amd64 binaries.
- Extract it to the same
$GOROOT
(~/go
in my case).
I prefer to not add the version number to my
go
installation folder. That way, when I want to update it, I simplyrm -rf
it and put in the new version.. and I don’t need to updateGOROOT
orPATH
. ↩︎You can refer to these official
go
references [ 1 ], [ 2 ] for further information on these variables. ↩︎