Introduction to Go

Go is a compiled, statically typed language created at Google to make building large, reliable software simple. It compiles to a single fast executable, has concurrency built into the language, and comes with a standard library and toolchain that cover most everyday needs. Docker, Kubernetes, Terraform and a large share of today's cloud infrastructure are written in Go. This course teaches Go 1.27.

What Go looks like

Here is a complete Go program. It adds up some prices and prints a summary:

GO
package main

import "fmt"

func main() {
	prices := []float64{4.50, 12.99, 3.25}

	total := 0.0
	for _, p := range prices {
		total += p
	}

	fmt.Printf("%d items, total %.2f\n", len(prices), total)
}
Output
3 items, total 20.74

Every Go file belongs to a package, a program starts in the main function of package main, and := declares a variable and lets Go work out its type. You'll run programs like this yourself in lesson 3.

Why learn Go?

  • Small and readable. Go has only 25 keywords and deliberately few ways to do each thing, so code written by other people looks familiar. One standard formatter, gofmt, ends arguments about style.
  • Fast to build and to run. Large programs compile in seconds into native machine code. There's no virtual machine to install: you ship one file.
  • Concurrency built in. Goroutines are so cheap that a server can run hundreds of thousands of them, and channels let them pass data safely.
  • Batteries included. The standard library has a production-quality HTTP server and client, JSON, cryptography, testing, profiling and much more.
  • One toolchain. The go command builds, runs, tests, formats, documents and manages dependencies. Cross-compiling for another operating system is a single environment variable.
  • In demand. Go is a top choice for back-end services, command-line tools, DevOps and cloud platforms.

Where Go is used

AreaExamples
Cloud infrastructureDocker, Kubernetes, containerd, etcd, Prometheus, Terraform
Web back ends and APIsHTTP and gRPC services at companies of every size
Command-line toolsThe GitHub CLI (gh), Hugo, many DevOps utilities
NetworkingProxies, load balancers, VPNs such as Tailscale, Caddy web server
Data and databasesCockroachDB, InfluxDB, pipelines and stream processors

A short history

YearMilestone
2007Robert Griesemer, Rob Pike and Ken Thompson start designing a new language at Google, frustrated by slow builds and complexity.
2009Go is announced as an open-source project.
2012Go 1.0, with the Go 1 compatibility promise: programs written for Go 1 keep compiling with later 1.x releases.
2018–2019Go modules replace the old GOPATH workflow for managing dependencies.
2022Go 1.18 adds generics.
2023–2024Go 1.21 to 1.23: built-in min, max and clear, a fresh loop variable per iteration, range over integers and over iterator functions.
2025–2026Go 1.25 to 1.27: WaitGroup.Go, new with an initial value, a faster garbage collector, generic methods, a new JSON implementation and a uuid package.

A new version arrives every February and August. Each release is supported until two newer ones are out, so in practice you should stay within a year of the latest release. Thanks to the compatibility promise, upgrading is usually painless.

How Go compares

If you know…Go will feel…
Python or JavaScriptStricter (every variable has a fixed type, checked when you compile) and much faster, but still concise. No classes, no exceptions.
Java or C#Lighter: no inheritance, no constructors, no annotations, no virtual machine. Interfaces are satisfied automatically.
C or C++Familiar syntax and pointers, but with garbage collection, bounds checking, no pointer arithmetic and no header files.

How this course works

Each lesson explains one topic with short, complete programs and their exact output. Every example was compiled and run with Go 1.27, and the output shown is what it produced. Examples that are meant to fail show the compiler's real error message; when a program crashes, the long stack trace is shortened to its first lines. Most lessons end with a Try it yourself editor: change the code, press Copy, and run it on your own computer.

Next: install Go so you can run every example yourself.