The previous chapter mapped out the Task API we are building; now we get your machine ready to build it. By the end of this chapter, you will have Go installed and watch your first program print Hello, Go!.
Go ships as a single installer with the compiler and the whole toolchain inside. There is no separate runtime to manage and no package manager to bootstrap first.
On macOS, you have two options:
bashbrew install go
On Windows, download the MSI from go.dev/dl. On Linux, follow the tarball instructions on the same page. Any recent version works for this course. The companion repository was built with go1.26.4, and nothing here depends on a feature newer than Go 1.22.
Once the installation finishes, confirm it from a terminal:
bashgo version
You should see the version and your platform printed back:

If you get a go: command not found error, the go binary is installed but missing from your PATH. Close and reopen your terminal. The installer updates your shell configuration, and only a fresh session picks up the changes. If the error persists, check your paths. Homebrew puts go on your PATH automatically, but the official package installs to /usr/local/go/bin, which you may need to add manually.
The go command has many subcommands. You will use a handful of them constantly. Here is what they do.

go run compiles the current package and runs it in one step. Use this during development when you want to see the program execute quickly.go build compiles the package into a standalone binary. You ship this binary. It requires no Go installation on the target machine.go fmt rewrites your code into the canonical Go style. Go avoids formatting debates because everyone runs the same formatter.go vet reports suspicious code that the compiler accepts but probably should not, such as a Printf format string that does not match its arguments.go test runs your tests. We will use this once we start testing the API later in the course.go mod manages your module and its dependencies. The first command you will run is go mod init, covered below.Run go help at any time to see the full list.
Older Go tutorials often mention GOPATH and a rule that all your code must live in one specific directory. Modern Go does not work that way.
A module is a collection of Go packages with a name and a list of dependencies. These are tracked in a file called go.mod. You create a module with go mod init and pass it a module path. This path is the import name for your code, usually the repository URL where it lives:
bashgo mod init github.com/mt26691/go-for-beginners
The command prints a short confirmation and writes a go.mod file:
textmodule github.com/mt26691/go-for-beginnersgo 1.26.4
The module line is the path you just chose. The go line records the Go version the module targets, which go mod init fills in based on your installed version. Your project can now live in any folder you like. This is the one piece of project setup you must not skip. If you run a build command in a directory with no go.mod, Go stops with a "go.mod file not found" error.
You can write Go in any editor, but the best beginner experience is VS Code with the official Go extension. Install the extension, open a .go file, and accept the prompt to install the Go tools. The most important tool is gopls, the official Go language server. It powers autocomplete, jump-to-definition, and error highlighting as you type.
Enable format-on-save so every file is formatted the moment you save it:
json{"editor.formatOnSave": true}
Now go fmt runs automatically. You no longer have to think about whitespace, and your code matches every other Go project immediately.
Every code chapter in this course has matching code in the companion repository. Clone it to your machine:
bashgit clone https://github.com/mt26691/go-for-beginners.gitcd go-for-beginners
The main branch holds the final, finished service. Each chapter also has two branches so you can follow along from any point:
-start branch: the project as it is when the chapter begins-finish branch: the project as it is when the chapter endsThe branch name is the chapter number plus a short description. For this chapter, the branches are 04-installing-go-start and 04-installing-go-finish. Chapters 1 through 3 had no code, so the companion code begins here at chapter 4. To begin where this chapter starts, check out the start branch:
bashgit checkout 04-installing-go-start
If you ever get stuck, check out the matching -finish branch to see the completed code.
The start branch gives you a skeleton: a go.mod and a main.go with an empty main function waiting to be filled in.
go// main.gopackage mainfunc main() {// TODO: write your first Go program here.}
Every Go program starts in package main. The func main block is the entry point that executes when the program starts. Right now main is empty, so the program compiles and runs but prints nothing. Update the file to print a greeting:
go// main.gopackage mainimport "fmt"func main() {fmt.Println("Hello, Go!")}
fmt is the standard library's formatting package, and fmt.Println prints a line of text. The import "fmt" line brings the package into your file. Go will not compile if you import a package you do not use, which is why the import was missing until we needed it.
Run it:
bashgo run .
The terminal prints Hello, Go!. The toolchain works end to end. If you want a standalone binary instead, build one:
bashgo build
go build produces an executable named after the module's last path segment. Here, you get a file called go-for-beginners that you can run directly with ./go-for-beginners. Open the project folder and you will see the new binary sitting alongside your source files:

The companion repository ignores this binary in its .gitignore file, ensuring compiled artifacts never land in version control.
If you reached this point, you have the same finished state as the 04-installing-go-finish branch.
Your environment runs Go, but you are still typing each command by hand. Next, we will wrap these commands in a Makefile and add golangci-lint. This allows you to catch mistakes early and run the entire project with a single short command.