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.
Here's a table of contents of what you'll learn in this lesson:
(click on a link to skip to its section)
Let's jump right in.
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 IDE’s 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:
- Point your browser to the Go downloads section and download the Microsoft Windows .msi installer.
- Launch the installer and follow the steps in the installation wizard to install Go on your system.
Confirm Go installation:
- Click on the Start/Windows button, type cmd and press Enter.
- In the Command Prompt window type the following command and press Enter.
If Go was installed correctly, you will see a message similar to the following output.
go version go1.x.x windows/amd64
How to install Go on Linux/Mac OS X
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.
Homebrew users can install Go with the following commands.
$ brew update $ brew install go
Linux / Mac tarball:
Download and extract the archive into /usr/local, creating a Go tree in /usr/local/go.
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.
- Point your browser to the Visual Studio Code downloads page.
- 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:
- Point your browser to the Go plugin page and click on the Install button.
- VSC will launch and present you with the plugin page. Click on the Install button again.
Install from inside the IDE:
- Launch Visual Studio Code and go to View > Extensions.
- In the search bar, type Go and press Enter.
- 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 .
If you’re interested, you can read more about the concepts covered in this lesson from the following sources: