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

Download and install

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

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

Accept the Go license agreement and click Next:

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:

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

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

Then check Golang version installed with $go version

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

Click on Environment Variables:

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.

Leave a Reply

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