A quick guide to some of the major Go topics we’ll learn about in my Mastery sessions, organised by subject area.
What makes Go special? Why learn Go today? What advantages does it have over other languages, and what makes it good for certain kinds of software? What’s unique about the tools Go gives us to solve problems?
Installation and getting started: Installing Go
on your computer, using the go tool, and enabling Go
support in IDEs such as VS Code, GoLand, and Zed. Setting up a
pleasant, modern Go development environment. Useful learning and training resources for Go.
The Go language: What kind of programming language is Go? How does it compare to Rust, Python, JavaScript, C++, and other popular languages? Where does Go come from, and where is it going? Go’s commitment to backward compatibility, and how the language has evolved.
Types: Go is a “strongly typed” language: what
does that mean, and why use types at all? How does the type system help
ensure our programs are correct? Representing numbers with key types
such as int and float64, and text with
string and char. Constants and the iota
keyword.
Structured data: Defining objects containing
multiple data values, using the struct keyword, and using
methods to associate behaviour with the data. Constructors, cleanup,
printing and formatting, and how default values work in Go.
Collections: Handling larger amounts of data in Go using arrays, slices, and maps.
Loops and conditionals: Repeated operations
using the for keyword, looping over collections with
range, and control flow using if and
switch statements.
Functions: How to define and call functions in
Go, arguments, return values, and what it means to say that “functions
are values”. Using closures (functions that can be called multiple times
while remembering their state in between calls). Cleaning up resources
using the defer
keyword.
Pointers: How Go programs share access to data using pointers, the difference between function or method arguments as pointers and as values, and some common pitfalls with pointers.
Code organisation: The structure of a Go
project, the go.mod file, packages and modules, visibility, imports,
dependencies, and documentation.
Error handling: Go’s error type and
how it’s used in APIs, handling
errors, wrapping errors with
custom information, and matching
errors against predefined types.
Generics and interfaces: Writing Go code that performs the same operations on many different types at once, whether those types are known at compile time (generics) or at run time (interfaces). Understanding the uses of generics, and the new generic standard library APIs.
Testing: Go’s built-in testing framework, executable examples, fuzz testing, testing command-line tools
with the testscript
package, and developing Go programs guided by tests.
Applications: Writing programs such as command-line tools, API clients, virtual machines, and container images.
Packages and modules: How and when to divide your program into independent packages or modules; adding, auditing, and updating dependencies.
The standard library: What you need to know
about Go’s powerful built-in library types and features; getting
familiar with key packages such as strings,
bytes, fmt. Interacting with the OS using
os, io, and filesystems, and with the Web via
net/http.
The wider ecosystem: The community’s favourite
solutions for command-line interfaces (cobra and
cli), testing (testify), database access
(sqlx), and Web servers (gin,
echo, and chi). Why Go programmers tend to
prefer the standard library over third-party frameworks, and how to make
pragmatic decisions about this.
Concurrency: Go’s built-in concurrent programming tools: goroutines for independently-executing tasks, and channels for message passing. Understanding the runtime scheduler, concurrency safety, and enforcing structured concurrency with concepts such as waitgroups and errgroups. Avoiding bugs such as deadlocks and data races using mutexes and atomic operations.
Iterators: Handling sequences of data one value
at a time using iterators, the
iter.Seq and Seq2 types, when functions should
be written as iterators, and how the new standard library iterator APIs
work.
Cryptography: Go’s standard library cryptography APIs, enciphering and deciphering with AES, managing passwords, keys, and randomness. Introduction to cryptocurrency and blockchains.
Idiomatic Go: What does it mean to write “idiomatic” Go, and what does that look like? How do you learn to think in Go, working with the grain of the language instead of against it? What is the “Zen of Go”?