Let’s learn to install Golang on the Windows Operating System.

Download Golang Installer for Windows

Visit the official website of Golang to find their releases

https://go.dev/dl/
Golang executable download for windows

You will see the different stable versions here. You may see a different stable version number when you open the official website of Golang. In our case, we will be installing the go1.22.4 version

Find the Windows installer and download the installer file. I have downloaded it in the Downloads Folder

Download golang in Windows

Install Golang on Windows

Double-click on the downloaded file to start the installation process and click on Next

Install golang on Windows

Select the Licence Agreement and click Next. Then choose the location where you want to install the Golang. we will keep the default location which is being shown in the installer and click Next

C:\Program Files (x86)\Go\
choose golang instllation location in Windows

Finally, click on Install to start the installation process. The installer will take some time to complete the installation.

Final installation of Golang on windows

The installer will automatically attach Golang to the PATH Environment variable

Validate Golang Installation on Windows

Open the Command Prompt and type the command go. If the installation is successful then it will output the result for go CLI

go

Define the GOPATH in Windows

The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string and on Windows, the value is a semicolon-separated string. On Plan 9, the value is a list. GOPATH must be set to get, build, and install packages outside the standard Go tree.

In our case, we will create a new directory go-projects in F drive and use it as GOPATH

F:\go-projects

This can be set in the environment variable of windows

Open Control Panel on Windows and then select System

Then click on the Advanced System setting. This will open a popup and you need to click Environment Variables on it

Click on Add New

This will ask you to define a Variable Name and Value

  • Variable Name: GOPATH
  • Variable Value: F:\go-projects
    • Note: The Variable Value will be different for you if you have chosen a different location.

Click on OK and this will create the GOPATH environment variable on your Windows machine.

This is the process to install Golang on Windows

References

Leave a Reply

Your email address will not be published. Required fields are marked *