Overview

Appendix A. Installation steps

Getting started focuses on installing the Go toolchain and confirming your setup. The text notes that Go’s compiler and tools have been written in Go itself since 1.3 and are open source, encouraging exploration of the standard library. Installation is straightforward on Linux, macOS, and Windows: download the installer, add Go to your PATH, and favor the latest release (the book uses Go 1.23). You can verify a successful setup from any directory by checking the version to confirm that Go is properly installed and available on your system.

Go relies on environment settings with sensible defaults, all visible via the go env command. While you rarely need to change them, values can be overridden temporarily with standard environment variables or persisted using go env -w, which writes to the configuration file indicated by GOENV. Key variables include GOBIN (where binaries installed via go install are placed), GOPATH (the set of directories used for resolving and caching dependencies; ensure your workspace is included), and GOROOT (the Go installation directory; avoid modifying it and keep its bin directory on PATH for tools like go and gofmt).

To validate the toolchain, create a small Hello World program, initialize a module with go mod init, and run it with go run. From there, you can bring in external work in two complementary ways: go install fetches and builds command-line tools as binaries into GOBIN, supporting explicit versions, latest, or project-scoped resolution; go get retrieves source dependencies for your project, updates go.mod, and downloads code into the module cache, with support for tags, branches, or specific commits. With these essentials, you can install Go, understand its environment, run your first program, and manage tools and libraries confidently.

A.6 Code editors

Go is supported by more and more code editors. As always in this situation, the best tool is the one you know how to use. The official Go website, as we write, lists three editors:

  • GoLand, by JetBrains. JetBrains has a long list of editors for various languages, the most famous being IntelliJ for Java. You can install GoLand as a standalone editor or add the Go plugin to any other editor in the list.
  • Visual Studio Code, by Microsoft, has a Go extension.
  • vim-go is great if you already know vim

A quick search around the web will easily give you instructions to add Go support to your usual tool, if it is not already there, e.g. with GoSublime, Atom with GoPlus, LiteIDE…

Go is now installed on your machine and you can start using it and follow the book’s instructions. We learned about the Go environment variables and important paths. Your terminal knows how to greet you in English using Go, you can move to Chapter 2 and teach it to greet you in other human languages.

FAQ

How do I install Go on my system?Visit https://go.dev/doc/install, download the installer for your OS (Linux, macOS, or Windows), run it, and add the Go binary directory to your PATH so the go command is available in your terminal.
Which Go version should I install?Install the latest stable Go release. The book was written using Go 1.23, and there’s generally no good reason to pick older versions.
How can I verify that Go is installed correctly?Open a terminal anywhere and run: go version. You should see output like: go version go1.xx.x youros/arch.
What does the go env command do?go env prints Go-specific environment variables, including defaults even if you didn’t set them in your shell. You can list all, or limit output, for example: go env -json GOBIN GOENV GOROOT GOPATH CGO_ENABLED.
How do I change Go environment variables?You can override them temporarily via standard env vars (e.g., on Linux: CGO_ENABLED=0 go env -json CGO_ENABLED) or persistently with: go env -w VARIABLE=VALUE. Persistent settings are stored in the file pointed to by GOENV.
What is GOBIN and how should I set it?GOBIN is the directory where go install module@version puts compiled tool binaries. Set it with: go env -w GOBIN=/path/to/bin and ensure that directory is on your PATH so installed tools are runnable.
What is GOPATH and why does it matter?GOPATH is a list of workspace directories Go uses, including where it caches dependencies (e.g., $GOPATH/pkg/mod). Make sure your workspace is included. Example: go env -w GOPATH=${GOPATH}:/path/to/workspace (on Windows use semicolons).
What is GOROOT and should I change it?GOROOT points to the Go installation directory. Don’t modify its contents or point other Go vars inside it. Ensure ${GOROOT}/bin is on your PATH; it contains go and gofmt.
How do I write and run a simple “Hello, World!” in Go?Create a folder (e.g., hello) with hello.go containing a main that prints “Hello, World!”. Initialize a module with: go mod init hello, then run: go run hello.go.
When should I use go install vs go get?Use go install for tools/binaries (compiles for your machine): go install repo/path/cmd@version or @latest. Use go get inside a module to add source dependencies to go.mod (and download them to $GOPATH/pkg/mod): go get module@version, where version can be a tag, branch (e.g., @master), or commit.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn Go with Pocket-Sized Projects ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn Go with Pocket-Sized Projects ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Learn Go with Pocket-Sized Projects ebook for free