Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Programming languages

Go

Go 1.27 from a first program to production services: types and slices, interfaces and errors, generics, concurrency, testing, HTTP, databases and tooling.

82 lessons to read 19 modules

82 lessons: 22 free with Pro answers and 60 with a free core.

Examples run with Go 1.27.1.

Who it is for

Back-end and cloud developers, and Python or Java developers moving to Go.

What you will be able to do

  • Install the Go 1.27 toolchain, run and build programs, and find answers in go doc and the specification
  • Write programs with Go's values, types, control flow, functions, closures and defer
  • Use arrays, slices, maps and strings correctly, and predict what append and copying do
  • Model data with structs, methods, embedding and interfaces, and handle errors as values
  • Organise code in packages and modules, and test it with table tests, fuzzing and benchmarks
  • Write generic code, including generic methods, and iterate with range-over-func iterators
  • Write concurrent programs with goroutines, channels, sync and context, and find races and leaks
  • Build HTTP and JSON services, database code, gRPC services and command-line tools
  • Profile, observe and secure Go services, and explain what the runtime does underneath
  • Answer Go interview and code-review questions with programs that prove each claim

Revise and practise

Modules and lessons

What the labels mean

Free lesson, Pro answers
the whole lesson is free; the model answers to its interview questions open with a pass
Free core, Pro depth
the core of the lesson is free; its in-depth parts open with a pass
Pro
opens with a Pro, Premium or Ultimate pass

Minutes are reading time: “5 of 15 min free” means 5 minutes of the lesson are free.

What a pass opens in this track

124 in-depth parts and 227 interview answers. The same pass opens every other track and every Pro tool.

  1. Module 1

    Getting started with Go 1.27

    What Go is for, installing the 1.27 toolchain, first programs and finding answers in the official docs.

    1. What Go is and where it fits Beginner Free lesson, Pro answers: 15 minutes
    2. Install Go 1.27 and set up your editor Beginner Free lesson, Pro answers: 15 minutes
    3. Your first Go program: go run and go build Beginner Free lesson, Pro answers: 15 minutes
    4. Find answers: go help, go doc and pkg.go.dev Beginner Free lesson, Pro answers: 15 minutes
  2. Module 2

    Basics: values, types and control flow

    Variables, zero values, numeric types, constants and iota, operators, control flow, fmt and input.

    1. Variables, short declarations and zero values Beginner Free lesson, Pro answers: 15 minutes
    2. Basic types: numbers, strings, bools, conversion Beginner Free core, Pro depth: 5 of 15 minutes free
    3. Constants, untyped values and iota Beginner Free core, Pro depth: 4 of 10 minutes free
    4. Operators, precedence and bit manipulation Beginner Free core, Pro depth: 4 of 10 minutes free
    5. Control flow: if, for, range and switch Beginner Free core, Pro depth: 6 of 15 minutes free
    6. Formatted output with fmt: verbs and widths Beginner Free core, Pro depth: 4 of 10 minutes free
    7. Reading input: lines, arguments and fast I/O Beginner Free core, Pro depth: 5 of 15 minutes free
  3. Module 3

    Functions, closures and defer

    Functions and multiple results, closures and per-iteration loop variables, defer, panic and recover.

    1. Functions, multiple results and variadics Beginner Free lesson, Pro answers: 10 minutes
    2. Closures: captured variables and loop variables Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. defer, panic and recover Intermediate Free core, Pro depth: 5 of 15 minutes free
  4. Module 4

    Arrays, slices, maps and strings

    Value semantics of arrays, slice internals and aliasing, the slices and maps packages, UTF-8 strings and number parsing.

    1. Arrays are values: length, copies, comparison Beginner Free lesson, Pro answers: 10 minutes
    2. Slices: length, capacity, append and aliasing Intermediate Free core, Pro depth: 5 of 15 minutes free
    3. The slices package: sort, search and compare Intermediate Free core, Pro depth: 6 of 15 minutes free
    4. Maps: lookups, sets, iteration and gotchas Beginner Free core, Pro depth: 6 of 15 minutes free
    5. Strings, bytes and runes: UTF-8 done right Intermediate Free core, Pro depth: 6 of 15 minutes free
    6. Numbers as text: strconv, bases and grouping Intermediate Free core, Pro depth: 6 of 15 minutes free
  5. Module 5

    Structs, pointers and methods

    Struct types and literals (including Go 1.27 promoted-field keys), pointers and new(expr), methods, embedding and constructors.

    1. Structs and struct literals, including Go 1.27 Beginner Free lesson, Pro answers: 15 minutes
    2. Pointers, new and escape analysis Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. Methods: value and pointer receivers Beginner Free core, Pro depth: 6 of 15 minutes free
    4. Embedding: composition instead of inheritance Intermediate Free core, Pro depth: 6 of 15 minutes free
    5. Constructors, useful zero values and options Intermediate Free core, Pro depth: 6 of 15 minutes free
  6. Module 6

    Interfaces and type assertions

    Implicit interfaces, interface values and the typed-nil trap, assertions and switches, standard interfaces, streaming I/O and enum patterns.

    1. Interfaces: implicit, small and consumer-defined Beginner Free lesson, Pro answers: 15 minutes
    2. Interface values, dynamic types and the nil trap Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. Type assertions and type switches Intermediate Free core, Pro depth: 6 of 15 minutes free
    4. Interfaces you will meet: Stringer to Handler Intermediate Free core, Pro depth: 6 of 15 minutes free
    5. Streaming data: io.Reader and io.Writer Intermediate Free core, Pro depth: 6 of 15 minutes free
    6. Enums and sum types: Go patterns that work Intermediate Free core, Pro depth: 6 of 15 minutes free
  7. Module 7

    Errors: values, wrapping, Is, As and AsType

    The error convention, wrapping and inspection (including errors.AsType from Go 1.26), custom error types and when to panic.

    1. Errors are values: returning and checking them Beginner Free lesson, Pro answers: 10 minutes
    2. Wrapping errors: %w, Is, As, AsType and Join Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. Custom error types and error design for APIs Intermediate Free core, Pro depth: 6 of 15 minutes free
    4. When to panic: runtime errors and Must helpers Intermediate Free core, Pro depth: 6 of 15 minutes free
  8. Module 8

    Coming from Python or Java

    Translation guides for the two most common first languages of Go developers, and the idioms reviewers expect.

    1. Go for Python developers: a translation guide Beginner Free lesson, Pro answers: 15 minutes
    2. Go for Java developers: a translation guide Intermediate Free core, Pro depth: 5 of 15 minutes free
    3. Idiomatic Go: naming, comments and style guides Intermediate Free core, Pro depth: 6 of 15 minutes free
  9. Module 9

    Packages, modules and dependencies

    Packages and visibility, go.mod and version selection, toolchains and GODEBUG, vetting dependencies, workspaces and private modules, layout and publishing.

    1. Packages, exported names and initialisation Intermediate Free lesson, Pro answers: 15 minutes
  10. Module 10

    Testing, fuzzing and benchmarks

    go test, table-driven tests, fakes and httptest, native fuzzing, b.Loop benchmarks, coverage and Example tests.

    1. Unit tests with go test Intermediate Free lesson, Pro answers: 20 minutes
    2. Table-driven tests, subtests and golden files Intermediate Free core, Pro depth: 8 of 20 minutes free
    3. Fakes, interfaces and httptest Intermediate Free core, Pro depth: 8 of 20 minutes free
    4. Native fuzzing with go test -fuzz Intermediate Free core, Pro depth: 6 of 15 minutes free
    5. Benchmarks with b.Loop Intermediate Free core, Pro depth: 6 of 15 minutes free
    6. Coverage, examples and test output Intermediate Free core, Pro depth: 8 of 20 minutes free
  11. Module 11

    Generics, including generic methods (1.27)

    Type parameters and inference, constraints and type sets, generic types and aliases, Go 1.27 generic methods, self-referential constraints and performance.

    1. Type parameters: generic functions and inference Intermediate Free lesson, Pro answers: 15 minutes
    2. Constraints, type sets and cmp.Ordered Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. Generic types, data structures and type aliases Intermediate Free core, Pro depth: 6 of 15 minutes free
    4. Generic methods in Go 1.27 Intermediate Free core, Pro depth: 6 of 15 minutes free
    5. Advanced generics: inference and self-reference Advanced Free core, Pro depth: 6 of 15 minutes free
    6. Generics in practice: performance and API design Advanced Free core, Pro depth: 6 of 15 minutes free
  12. Module 12

    Iterators and range-over-func

    Push iterators with iter.Seq, the standard library's iterator functions, pull iterators and lazy generic pipelines.

    1. Range-over-func iterators with iter.Seq Intermediate Free lesson, Pro answers: 15 minutes
    2. Iterators in slices, maps, strings and reflect Intermediate Free core, Pro depth: 7 of 20 minutes free
    3. Pull iterators and lazy pipelines with generics Advanced Free core, Pro depth: 8 of 20 minutes free
  13. Module 13

    Goroutines, channels and sync

    Goroutines and the scheduler, channels, select and timers, WaitGroup.Go and mutexes, atomics and the memory model, the race detector and synctest virtual time.

    1. Goroutines and the Go scheduler Intermediate Free lesson, Pro answers: 15 minutes
    2. Channels: unbuffered, buffered, closed and nil Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. select, timeouts, timers and tickers Intermediate Free core, Pro depth: 5 of 15 minutes free
    4. sync: WaitGroup.Go, Mutex, RWMutex and Once Intermediate Free core, Pro depth: 6 of 15 minutes free
    5. Atomics and the Go memory model Advanced Free core, Pro depth: 7 of 20 minutes free
    6. Testing concurrent Go code with synctest Advanced Free core, Pro depth: 8 of 20 minutes free
  14. Module 14

    context and cancellation

    Cancellation, deadlines and values with context, cancellation causes and AfterFunc, and deadline budgets across a service.

    1. context: cancellation, deadlines and values Intermediate Free lesson, Pro answers: 15 minutes
    2. Cancellation causes, AfterFunc and WithoutCancel Intermediate Free core, Pro depth: 8 of 20 minutes free
    3. Deadlines across a service: budgets and retries Advanced Free core, Pro depth: 7 of 20 minutes free
  15. Module 15

    Concurrency patterns in Go

    Pipelines, worker pools and semaphores, errgroup, rate limiting, goroutine-leak detection, caches, singleflight and pub/sub.

    1. Pipelines, fan-out and fan-in Intermediate Free lesson, Pro answers: 15 minutes
    2. Worker pools, semaphores and bounded parallelism Intermediate Free core, Pro depth: 8 of 20 minutes free
    3. Goroutine leaks and the goroutineleak profile Advanced Free core, Pro depth: 6 of 15 minutes free
    4. Concurrent caches, singleflight and pub/sub Advanced Free core, Pro depth: 6 of 15 minutes free
  16. Module 16

    Standard library essentials

    Files and io/fs, traversal-safe access with os.Root, time and IST time zones, slog, regexp and templates, crypto, randomness and uuid.

    1. Files, directories and io/fs Intermediate Free lesson, Pro answers: 10 minutes
    2. Safe file access with os.Root Intermediate Free core, Pro depth: 6 of 15 minutes free
    3. Time, durations, layouts and time zones (IST) Intermediate Free core, Pro depth: 6 of 15 minutes free
    4. Structured logging with slog Intermediate Free core, Pro depth: 4 of 10 minutes free
    5. Regular expressions (RE2) and HTML templates Intermediate Free core, Pro depth: 6 of 15 minutes free
    6. Hashing, randomness, UUIDs and password storage Intermediate Free core, Pro depth: 6 of 15 minutes free
  17. Module 17

    JSON: encoding/json and encoding/json/v2

    encoding/json with omitzero and streaming, the Go 1.27 encoding/json/v2 and jsontext packages, and a safe migration plan.

    1. JSON with encoding/json: tags, omitzero, streams Intermediate Free lesson, Pro answers: 15 minutes
    2. JSON v2 in Go 1.27: encoding/json/v2 and jsontext Advanced Free core, Pro depth: 8 of 20 minutes free
    3. Migrating a service from JSON v1 to v2 safely Advanced Free core, Pro depth: 8 of 25 minutes free
  18. Module 18

    HTTP servers and clients with net/http

    ServeMux patterns, middleware, JSON APIs with validation, production server settings, robust clients, HTTP testing and framework choices.

    1. HTTP servers with ServeMux method and path patterns Intermediate Free lesson, Pro answers: 15 minutes
    2. Middleware, request context and ResponseController Intermediate Free core, Pro depth: 10 of 25 minutes free
    3. JSON APIs: decoding limits, validation and errors Intermediate Free core, Pro depth: 7 of 20 minutes free
    4. Production servers: timeouts, shutdown, TLS, CSRF Advanced Free core, Pro depth: 8 of 25 minutes free
  19. Module 22

    Tooling: vet, fix, linters, generate and builds

    Static analysis, go fix modernizers, code generation with tool directives, builds and cross-compilation, cgo and WebAssembly.

    1. go vet, staticcheck and golangci-lint Intermediate Free lesson, Pro answers: 15 minutes
    2. Modernise code with go fix and //go:fix inline Intermediate Free core, Pro depth: 6 of 15 minutes free

Related tools

Official documentation

More in Programming languages

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.