Set Up Your Language · 12 of 14
Setting Up Go
Go (also called Golang) was created at Google to be simple and fast. It is used for web servers, cloud services and command-line tools; well-known tools such as Docker and Kubernetes are written in it. Go builds a single .exe file that needs nothing else to run.
New to all this? Read Before you start on the main page first: it shows how to open Terminal, make a folder for your code, and see file name endings. It takes five minutes and prevents most problems.
1 What to download, and from where
Download only from go.dev, the official Go website. Other download sites can bundle unwanted software.
- Go to go.dev/dl.
- Under Featured downloads, click Microsoft Windows (a
.msifile for x86-64; choose ARM64 only if your computer has an ARM processor).
2 Install it on Windows
- Open the downloaded
.msifile. Click Next, accept the licence, keep the suggested folder, and click Install. - Click Yes if Windows asks, then Finish.
3 Check that it worked
Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. Then type this and press Enter:
go versionWhat you will see: The word go, a version number and windows/amd64 (amd64 simply means 64-bit, also for Intel processors).
go version go1.25.4 windows/amd64
If you see an error such as "is not recognized" instead, look at the common mistakes at the bottom of this page.
4 Write and save your first program
A program is just a text file. You can write it in Notepad, which comes with Windows. (Later you may like the free Visual Studio Code editor from code.visualstudio.com, which colours the code and helps spot mistakes.)
- Open Notepad (press the Windows key, type Notepad, press Enter).
- Type the program below, or click Copy and paste it in with Ctrl + V. Every symbol matters, so copy it exactly.
package main import "fmt" func main() { fmt.Println("Hello, World!") } - In Notepad choose File → Save as. Go to your
C:\codefolder. Set Save as type to All files (*.*), type the file namehello.goexactly as shown, including the dot and the ending, and click Save.
package main says this is a program you can run. import "fmt" brings in Go's formatting and printing tools. func main() is where it starts, and fmt.Println prints a line.
Do not use Word. Word saves extra formatting and changes straight quotes " into curly ones “ ”, which no programming language accepts.
5 Run it and see the result
Open File Explorer, go into your C:\code folder, right-click an empty part of the window and choose Open in Terminal. (More ways to open Terminal.) If Terminal was already open from the check above and is in another folder, type cd C:\code and press Enter.
Type this and press Enter:
go run hello.goWhat you will see: the words below on a new line. That is your program running.
Hello, World!
go run builds and runs in one step. To make an .exe you can share, run go build hello.go, which creates hello.exe.
Congratulations: you have written and run a Go program.
6 Common beginner mistakes and how to fix them
Error messages look alarming but are usually precise: read the first line, and look for a line number. If you are stuck, copy the whole error message and paste it into an AI assistant along with your code, and ask what it means.
"os" imported and not used
Why: Go refuses to build a program that imports something it never uses. You will see this as you experiment.
Fix: delete the unused import line, or use it.
go: go.mod file not found in current directory or any parent directory
Why: you typed go build or go run . without a file name. Those work on a Go module (a project), which needs a go.mod file.
Fix: give the file name, go run hello.go, or create a module once with go mod init hello.
'go' is not recognized as an internal or external command
Why: Windows cannot find the program. Either the Terminal was open before you installed it, or the program's folder is not on the PATH (the list of folders Windows searches for commands).
Fix: Close every Terminal window you have open and open a new one. A Terminal that was already open does not know about programs installed after it started. If it still fails, restart the computer, then check the folder is on the PATH (how to check and add it).