Lumenary CS · Programming languages
Go
A small, fast, statically typed language built for networked services and the teams that maintain them, from a first program to professional practice.
Go is a compiled, garbage-collected language designed at Google and released as open source in 2009. It favours a small set of features that combine well, very fast builds, a single standard format for code, and concurrency built into the language with goroutines and channels. Much of today's cloud infrastructure is written in it, including Docker, Kubernetes, Terraform and Prometheus, along with countless web services, command-line tools and network programs.
This course is for anyone who already knows what a variable, a loop and a function are: the Start level of Lumenary CS or equivalent experience in any language. It begins with installing Go and running a first program, covers the core language and its standard library, then the ideas that make Go distinctive (interfaces satisfied implicitly, errors as values, generics, goroutines and channels), and ends with testing, tooling and a complete small web service with JSON, written the way Go teams write it.
To run the code, download Go from go.dev/dl (installers for Linux, macOS and Windows), or paste any program into the Go Playground. Every complete program in these lessons was run by Lumenary's test suite with Go 1.27, and the output shown is the output it printed. The lessons were drafted with AI assistance and are awaiting review by a human computer scientist.
- Chloe · The Designer
“Why is the language built this way?” - Margaret · The Profiler
“What does it print, and what does it cost?” - Gideon · The Language Lawyer
“What exactly does the language guarantee?”
Foundations · 4 lessons
Foundations
Install Go, organise code in modules, and learn the core language: types, control flow, functions with multiple results, and slices, maps and strings.
- 1Getting started with GoWhy Go was made, how to install it, and your first programs with modules, go run and fmt. 45 min
- 2Types, variables and control flowDeclarations, zero values, numbers and constants, and Go's three control structures: if, for and switch. 50 min
- 3Functions, closures and deferMultiple results, variadic parameters, functions as values, closures, pointers, and defer for clean-up. 50 min
- 4Slices, maps and stringsGo's workhorse data structures, how they share memory, and how text really works in UTF-8. 55 min
Practice · 3 lessons
Practice
Model data with structs and methods, abstract with small interfaces, handle errors as values, and write reusable code with generics and iterators.
- 5Structs, methods and interfacesData with behaviour, composition by embedding, and small interfaces satisfied without being declared. 60 min
- 6Errors as valuesReturning, wrapping and inspecting errors, custom error types, errors.Is and errors.As, and where panic and recover fit. 55 min
- 7Generics and iteratorsType parameters and constraints, generic types and methods, and range-over-func iterators. 60 min
Professional · 3 lessons
Professional
Write concurrent programs with goroutines, channels, sync and context; test, benchmark, fuzz and profile them; and build a small JSON web service the way Go teams do.
- 8Goroutines, channels, select and contextGo's model of concurrency, its standard patterns, and the tools that keep concurrent code correct. 65 min
- 9Testing, profiling and toolinggo test with table-driven tests, examples, benchmarks and fuzzing; and gofmt, go vet, pprof and the rest of the professional toolkit. 60 min
- 10HTTP, JSON and a complete serviceThe standard library's HTTP server and client, encoding/json, and a small JSON API built and tested the way Go teams do it. 70 min
Further reading and resources
- The Go websiteDownloads, documentation, the blog, and links to the community.
- Go documentationTutorials, Effective Go, the FAQ, release notes and more.
- The Go Programming Language SpecificationThe language definition: short and readable enough to read in an afternoon.
- Standard library documentationEvery package in the standard library, with examples.
- A Tour of GoThe official interactive introduction, runnable in the browser.
- Effective GoThe classic guide to writing idiomatic Go.
- The Go PlaygroundRun and share Go programs in the browser.