Install Golang on Windows [Step-by-Step]


GO

Author: Tuan Nguyen
Reviewer: Deepak Prasad

Today's post will guide you through the detailed steps to install Go on Windows. Go is an open-source and statically typed programming language developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009. It is also known as the Golang and it supports the procedural programming language. It’s really simple to install Golang on Windows, please follow the below steps

 

Method-1: Install GoLang from official archive

 

Step-1: Installing git [Optional]

We need version control software to manage go projects and download libraries. In this tutorial, we will use Git. Go to the download page and choose the latest (2.38.1) 64-bit version of Git for Windows. This is the most recently maintained build. Run the .exe file and follow the guide to install Git on Windows:

Install Golang on Windows [Step-by-Step]

Go should be checked to see if it is already installed on your system before we start the installation process. Go to the Command line to see if Golang is already installed on your device.

go version

If Golang is already installed, a message including all the details of the version that are available will be generated; otherwise, if Golang is not installed, an error stating Bad command or file name will be generated.

 

Step-2: Downloading Go

The first step is to download Golang. For that, all versions of Go for Windows are available on golang.org. Choose your version and click download the msi file (for example https://go.dev/dl/go1.19.3.windows-amd64.msi)

Install Golang on Windows [Step-by-Step]

 

Step-3: Install go from .msi file

After launching the installer (.msi file) the installer will begin:

Install Golang on Windows [Step-by-Step]

 

Accept the Go license agreement and click Next:

Install Golang on Windows [Step-by-Step]

 

There is already a value in the destination Go installation. Simply click Change if you want to make changes. But leaving it at its default setting is recommended:

Install Golang on Windows [Step-by-Step]

 

To start the installation, click Install. Windows will request administrative permission to install Go, just accept Yes:

Install Golang on Windows [Step-by-Step]

 

Click Finish to complete the setup after it has finished installing:

Install Golang on Windows [Step-by-Step]

 

Step-4: Check GoLang version installed

To check the GoLang version that is installed, go to cmd and use the command below:

go version

The system will prompt the installed go version:

Install Golang on Windows [Step-by-Step]

 

Step-5: Setup GOPATH

The Go compiler needs a way to know how to find our source files (packages) so that the compiler can build and install them. The compiler utilizes two environmental variables for this job. $GOROOT and $GOPATH tell the Go compiler where to search for the locations of the Go packages listed by the import statement.

The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. 

GOPATH must be set to get, build and install packages outside the standard Go tree.

To verify setting up these environment, search Environment and click Edit system Environment variables

Install Golang on Windows [Step-by-Step]

 

Click on Environment Variables:

Install Golang on Windows [Step-by-Step]

You can set GOPATH to any folder you prefer. To change GOPATH just click Edit and then either write the path or browse the folder.

 

Method-2: Install Golang using Chocolatey

Chocolatey is a package management for Windows. Chocolatey has the largest online registry of Windows packages. Chocolatey packages encapsulate everything required to manage a particular piece of software into one deployment artifact by wrapping installers, executables, zips, and/or scripts into a compiled package file.

Requirements

  • Windows 7+ / Windows Server 2003+
  • PowerShell v2+ (minimum is v3 for install from this website due to TLS 1.2 requirement)
  • .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed)(minimum is 4.5 for install from this website due to TLS 1.2 requirement)

 

Install Chocolatey with powershell

Ensure that you are using an administrative shell - you can also install as a non-admin, check out Non-Administrative Installation.

With PowerShell, you must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass -Scope Process.

Now run the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Paste the copied text into your shell and press Enter and wait a few seconds for the command to complete.

If you don't see any errors, you are ready to use Chocolatey! Type choco or choco -? to check if choco already installed.

Install Golang on Windows [Step-by-Step]

 

Install Golang using chocolatey

To install Go Programming Language, run the following command from the command line or from PowerShell:

choco install golang

 

Summary

Go on Windows 10 is comparatively easy to install. Downloads for all platforms that are supported are available from the Golang website. Simply download the file, double click it, and finish the installation on Windows 10. You can also use Chocolatey - package management for Windows to install Go.

 

References

https://go.dev/doc/install
https://en.wikipedia.org/wiki/Windows_Installer

 

Tuan Nguyen

Tuan Nguyen

He is proficient in Golang, Python, Java, MongoDB, Selenium, Spring Boot, Kubernetes, Scrapy, API development, Docker, Data Scraping, PrimeFaces, Linux, Data Structures, and Data Mining. With expertise spanning these technologies, he develops robust solutions and implements efficient data processing and management strategies across various projects and platforms. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment