Emacs, scripting and anything text oriented.

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.

<2018-05-17>
Add “Updating go” section.
Table of Contents

There are two reasons why I suggest installing go to anyone, whether they are Go developers, or not (like me).

  1. You can then build amazing utilities like peco, hugo and noti.
  2. It’s easy!

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.

  1. Download the tar.gz for the latest linux-amd64 binaries from https://golang.org/dl/.
  2. Extract it to some place in your $HOME. I extract it to ${HOME}/go/1.
  3. Create a directory where you would want to install the go packages.
    mkdir -p ~/go.apps
    
  4. 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
    
  5. 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 #

  1. Delete the existing $GOROOT directory (not GOPATH!)
    rm -rf ~/go   # as that is my GOROOT
    
  2. Download the tar.gz for the latest linux-amd64 binaries.
  3. Extract it to the same $GOROOT (~/go in my case).

  1. I prefer to not add the version number to my go installation folder. That way, when I want to update it, I simply rm -rf it and put in the new version.. and I don’t need to update GOROOT or PATH↩︎

  2. You can refer to these official go references [ 1 ], [ 2 ] for further information on these variables. ↩︎