How to Install Go on Windows?

Nova Novriansyah
NovAi-Go Programming 101
3 min readJun 9, 2024

Step 1: Download Go Installer

  1. Visit the Go download page:
  • Go to the official Go download page.
  • Download the Windows installer (MSI file) appropriate for your system architecture (most likely the 64-bit installer).
Visit the go download page
Download Windows installer

Step 2: Run the Installer

  1. Open the downloaded MSI file:
  • Double-click the MSI file to run the installer.
Start the Go Installer

2. Follow the installation prompts:

  • Click “Next” to proceed with the installation.
  • Accept the license agreement.
  • Choose the installation directory (the default is usually fine).
  • Complete the installation by clicking “Install” and then “Finish”.
Complete Go Installer

Step 3: Set Up Environment Variables

  1. Open Environment Variables:
  • Right-click on “This PC” or “My Computer” and select “Properties”.
  • Click on “Advanced system settings”.
  • Click on the “Environment Variables” button.
This Computer properties
Open Advance System Settings

2. Update the PATH variable:

  • In the “System variables” section, find the Path variable and select it.
  • Click “Edit” and add the path to the Go bin directory. By default, this is C:\Go\bin.

3. Create a workspace directory:

  • Create a directory for your Go workspace, e.g., C:\Users\<YourUsername>\go.

4. Set the GOPATH environment variable:

  • In the “User variables” section, click “New” and create a variable named GOPATH with the value set to your workspace directory (e.g., C:\Users\<YourUsername>\go).
Open Environment Variable and set GoPath

Step 4: Verify the Installation

  1. Open Command Prompt:
  • Press Win + R, type cmd, and press Enter to open the Command Prompt.

2. Check the Go version:

  • Type go version and press Enter. You should see the installed Go version displayed.

Step 5: Create and Run a Simple Go Program

  1. Create a new directory for your project:
  • In the Command Prompt, navigate to your workspace directory
cd %GOPATH%
mkdir -p src/hello
cd src/hello

2. Create a Go file:

  • Open your favorite text editor and create a file named hello.go with the following content in the hello directory:
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}

3. Run the Go program:

  • In the Command Prompt, navigate to the directory where hello.go is located and run the program:
go run hello.go
  • You should see Hello, World! printed in the Command Prompt.

Congratulations! You have successfully installed Go on Windows and run your first Go program.

--

--

Nova Novriansyah
NovAi-Go Programming 101

C|CISO, CEH, CC, CVA,CertBlockchainPractitioner, Google Machine Learning , Tensorflow, Unity Cert, Arduino Cert, AWS Arch Cert. CTO, IT leaders. Platform owners