Go (or Golang) is a powerful, open-source programming language developed by Google. It is widely used for building scalable and high-performance applications. If you're a Windows user, this guide will walk you through the installation and setup of Go on your system.
Prerequisites
Before installing Go, ensure you have:
A Windows 10 or later operating system.
Administrator access to install software.
A stable internet connection.
Step 1: Download the Go Installer
Open your browser and visit the official Go website: go.dev/dl
Look for the latest Windows version of Go (e.g.,
go1.x.x.windows-amd64.msi
).Click on the download link to save the
.msi
file.
Step 2: Install Go on Windows
Locate the downloaded
.msi
file and double-click to run the installer.Click Next on the welcome screen.
Accept the license agreement and click Next.
Choose the installation destination (default is
C:\Go
), then click Next.Click Install and wait for the installation to complete.
Click Finish to exit the installer.
Step 3: Set Up Environment Variables
To ensure Go works properly, you need to verify its environment variables:
Open the Start Menu, search for Environment Variables, and open Edit the system environment variables.
In the System Properties window, click Environment Variables.
Under System Variables, locate
Path
and click Edit.Ensure
C:\Go\bin
is listed. If not, click New, enterC:\Go\bin
, and click OK.Click OK on all windows to save changes.
Step 4: Verify Go Installation
To confirm Go is installed correctly:
Open Command Prompt (
cmd
) or PowerShell.Type the following command and press Enter:
go version
You should see an output similar to:
go version go1.x.x windows/amd64
If you see this, Go is installed successfully!
Step 5: Set Up Go Workspace
Open File Explorer and navigate to your user directory (
C:\Users\YourUsername
).Create a new folder named
go
(this will be your workspace).Inside the
go
folder, create three subfolders:bin
(for compiled binaries)pkg
(for compiled package objects)src
(for Go source code)
Open Command Prompt and run:
go env
This displays your Go environment variables. Ensure
GOPATH
is set toC:\Users\YourUsername\go
.
Step 6: Create and Run Your First Go Program
Open a text editor (such as Notepad++ or VS Code) and create a new file named
hello.go
insideC:\Users\YourUsername\go\src
.Add the following code:
package main import "fmt" func main() { fmt.Println("Hello, Go!") }
Open Command Prompt, navigate to the
src
directory:cd C:\Users\YourUsername\go\src
Compile and run the Go program:
go run hello.go
You should see:
Hello, Go!
Conclusion
You have successfully installed and set up Go on Windows! Now you can start exploring Go programming by creating projects and building applications. If you encounter any issues, refer to the official Go documentation: go.dev/doc.
Happy coding!