How to Install and Setup Environment for Go/Golang on Windows

In this tutorial, you will learn how to download, install and set environment for Go programming language on Windows.

  1. The first thing you'll need to do is go the the official website of Go programming language at https://go.dev/dl/ and download Go installer for Microsoft Windows.
  2. After downloading the Go installer, double click on it to start the installation process.
  3. Install it with the default installation settings and steps.
  4. Now, its time to set up an environment variable path for Go.
  5. Type env in the search and click on the Edit the system environment variables shortcut as shown in the image below:
  6. On the System Properties window, click Environment Variables button.
  7. Under System variables, click New.
  8. Enter GOPATH in the Variable name field. Browse and select the Go installation directory in the Variable value field as shown below:
  9. Choose OK button and restart your computer.
  10. Verify the installed version of Go by executing the following command on your terminal:

    
        go version
    

    The above command should print something like below:

    go version go1.17.5 windows/amd64
  11. Next, download Visual Studio Code IDE at https://code.visualstudio.com/download and install it.
  12. After the installation of Visual Studio Code IDE, launch it and install extension for Go as shown in the image below:
  13. Environment setup for the Go programming language is complete. Now, you can work on creating and running Go programs.