Install Go, put it on your PATH, and build a project you can run. Start here if you have never written any Go.
Install Go
1 Download the official build
Everything you need is one download from go.dev/dl. Take the file for your operating system and processor.
Apple machines built since 2020 are arm64. Almost everything else is amd64.
go1.26.1.darwin-arm64.pkg macOS
go1.26.1.windows-amd64.msi Windows
go1.26.1.linux-amd64.tar.gz Linux2 Run the installer, or unpack the archive
On macOS and Windows the download is an installer. Open it, click through, and it puts Go where it belongs.
Linux is a tar archive you unpack yourself. Removing the old folder first keeps two versions from mixing.
# Linux, from the folder you downloaded into.
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.26.1.linux-amd64.tar.gz3 Put Go on your PATH
This is the step people get stuck on. Your shell only finds a program if the folder holding it is listed in PATH, and the Linux archive does not touch your shell.
The second line covers the tools you install later with go install, which land in your Go workspace rather than beside Go itself.
The macOS and Windows installers do both for you. Open a new terminal afterwards so it picks up the change.
# Add these two lines to ~/.zshrc, or ~/.bashrc on bash.
export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$(go env GOPATH)/bin$ source ~/.zshrc4 Check that it worked
A version means you are done installing. "command not found" means the folder from step 3 is missing from your PATH, or the terminal you are typing in was already open when you added it.
$ go version
go version go1.26.1 linux/amd64Make your first project
5 Create a folder and a module
A module is a folder with a go.mod file in it. That file names the module and pins the Go version, and every project you build needs one.
The name is what other people would type to import your code, so it is normally where the code lives: github.com/you/hello. Nothing checks it while you are learning.
$ mkdir hello
$ cd hello
$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello6 Write main.go and run it
Create main.go next to go.mod and put this in it. go run . compiles the folder and runs what comes out.
package main
import "fmt"
func main() {
fmt.Println("Hello from Go.")
}$ go run .
Hello from Go.What a project looks like
Your folder holds two files right now. Here is where the rest goes as the program grows, and what each part is for.
Nothing here is generated for you. Make the folders you need, put a package clause at the top of every file, and Go works the rest out from the module path.
Go on your PATH, a folder with a go.mod in it, and a program that prints a line.