Go Environment Setup Tutorial

In this Go tutorial we learn how to set up a development environment by installing the Go distribution and Microsoft's Visual Studio Code IDE.

Development environment for Go

Before we can start learning how to code and create programs with Go, we need a development environment.

A Go development environment consists of the following:

  • The Go distibution, to be able to compile and run Go apps.
  • A text editor or IDE (integrated development environment).

The IDE or text editor you use is up to you, most well-known IDEs have some form of Go integration.

In this tutorial course, we’ll use Visual Studio Code with the Go plugin from Microsoft.

How to install Go on Windows

Please follow the steps below to install the Go distribution on Windows:

  1. Point your browser to the Go downloads section and download the Microsoft Windows .msi installer.
  2. Launch the installer and follow the steps in the installation wizard to install Go on your system.

Confirm Go installation:

  1. Click on the Start/Windows button, type cmd and press Enter.
  2. In the Command Prompt window type the following command and press Enter.
Command Prompt:
 go version

If Go was installed correctly, you will see a message similar to the following output.

Output:
 go version go1.x.x windows/amd64

How to install Go on Linux/Mac OS X

Mac Installer:

It’s recommended to download and use the latest installer for Mac from the Go downloads section .

If you prefer the tarball, you can follow the same steps below as Linux users.

Mac Homebrew:

Homebrew users can install Go with the following commands.

Homebrew:
$ brew update
$ brew install go

Linux / Mac tarball:

Download and extract the archive into /usr/local, creating a Go tree in /usr/local/go.

Example:
 tar -C /usr/local -xzf go1.13.6.linux-amd64.tar.gz

Go with Visual Studio Code

Please follow the steps below if you want to set up a Go development environment in Visual Studio Code.

  1. Point your browser to the Visual Studio Code downloads page.
  2. Choose a download based on your operating system and install VSC once the download has finished.

Once VSC has been installed, we can add the Go extension from Microsoft.

Install from the website:

  1. Point your browser to the Go plugin page and click on the Install button.
  2. VSC will launch and present you with the plugin page. Click on the Install button again.

Install from inside the IDE:

  1. Launch Visual Studio Code and go to View > Extensions.
  2. In the search bar, type Go and press Enter.
  3. Click on the first result and then the install button on the plugin page.

Go to View > Explorer to show the file explorer again.

Visual Studio Code may want to install additional extensions for Go, such as goreturns or gocode. These extensions are useful, but not required, and can be installed by choosing Install or Install All.

If you receive errors installing the extensions, you may need to download and install Git .

Further reading

If you’re interested, you can read more about the concepts covered in this lesson from the following sources: