Installing Go on Windows
Before you can start programming in Go, you need to have it installed on your computer. This tutorial will guide you step-by-step on how to install Go (or Golang) on a Windows system.
Pre-requisites
You will need:
- A computer with Windows operating system.
- Internet connection to download the necessary files.
- Administrative privileges on your computer to install the software.
Step 1: Download the Go Installer
You can download the Go installer from the official website. Here is the link: Go Downloads
Download the version for Windows. As of writing this tutorial, the latest stable version is 1.16.3.
Step 2: Running the Installer
Once the download is complete, locate the installer file. It should be named something like go1.16.3.windows-amd64.msi
.
Double click on the installer file to start the installation process. If prompted by User Account Control, click on 'Yes' to allow the installer to make changes to your device.
Step 3: Go through the Installation Wizard
When the installer launches, you will see the Go programming language Setup wizard. Click 'Next' to continue.
You will then be prompted to choose a location for the installation. By default, Go will be installed in the C:\Go
directory. You can change this if you wish, but for the sake of this tutorial, we will stick with the default location. Click 'Next' to continue.
Then, you will be shown the license agreement. Take a minute to read it, then click on 'I Agree' to continue the installation.
Finally, click 'Install' to start the installation process.
Step 4: Finishing the Installation
Once the installation process is finished, click on 'Finish'. The installer will close, and Go will be installed on your computer.
Step 5: Verifying the Installation
You can verify that Go was installed correctly by opening a command prompt and typing the following command:
go version
If Go has been installed correctly, you should see something like this:
go version go1.16.3 windows/amd64
This command displays the version of Go that is currently installed on your system.
Step 6: Setting up the Go Workspace
Go requires a specific workspace layout to function properly. This workspace includes three folders: src
(for source files), pkg
(for package objects), and bin
(for executable commands).
By default, Go assumes your workspace is located in a directory named go
inside your user's home directory. For example, C:\Users\YourName\go
on Windows.
To create this directory structure, run the following commands in your command prompt:
mkdir %USERPROFILE%\go\src
mkdir %USERPROFILE%\go\pkg
mkdir %USERPROFILE%\go\bin
Conclusion
That's it! You have successfully installed Go on your Windows system and set up your Go workspace. Now you're ready to start programming in Go! If you run into any issues, the Go community is very active and you can find help through multiple online forums. Happy coding!