Luca Sepe

Installing and Upgrading Go tools

Go

Eventually remove the existing version

If you are upgrading from an older version of Go you must first remove the existing version.

  • simply delete the go directory - usually /usr/local/go under Linux, macOS, and FreeBSD or c:\Go under Windows
sudo rm -rf /usr/local/go

Windows - Download the Go distribution

Binary distributions are available @ https://golang.org/dl/.

For Windows it's available the MSI installer that by default

  • puts the Go distribution in c:\Go
  • put the c:\Go\bin directory in your PATH environment variable

Linux, macOS and FreeBSD - Download the Go distribution

Binary distributions are available @ https://golang.org/dl/.

For Linux, macOS and FreeBSD we can download the tarballs:

curl -LO https://dl.google.com/go/goX.Y.Z.linux-amd64.tar.gz
flag meaning
-L follow redirects
-O write output to a file named as the remote file

Linux, macOS and FreeBSD - Extract the tarball

Once the archive is downloaded we have to extract it to the /usr/local folder.

sudo tar -C /usr/local -xzf goX.Y.Z.linux-amd64.tar.gz
flag meaning
-C /usr/local change to directory /usr/local
-z filter the archive through gzip
-x extract files from an archive
-f go1.14.1.linux-amd64.tar.gz use this archive file

Linux, macOS and FreeBSD - Update the PATH environment variable

We can do this by adding this line to our /etc/profile (for a system-wide installation) or $HOME/.profile:

export PATH=$PATH:/usr/local/go/bin

Installing the Go plugin for Visual Studio Code

Launch VS Code Quick Open (Ctrl+P) and enter the following command:

ext install ms-vscode.Go

For the full list of settings and their descriptions visit:

https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go