Glossary
127 terms from Go in Practice, in plain words, each with the chapter that teaches it.
#
- -fuzz / -fuzztime
- `go test -fuzz=Name` starts fuzzing one fuzz test, and `-fuzztime` stops it after a set time if nothing fails. Without `-fuzztime` it runs until it finds a failure or you press Ctrl+C.
- -pgo
- A Go build option (profile-guided optimization) that uses a CPU profile of a running program to build a faster binary.
- -s -w; -X
- Linker flags passed through `-ldflags` (and `-o` names the output file of `go build`). `-s -w` leave out the symbol table and debug information to make the binary smaller, and `-X` sets a string variable such as `main.version` at build time.
- -trimpath
- A `go build` flag that removes your folder names from the binary. The binary then doesn't reveal your machine's layout and builds the same anywhere.
- .dockerignore
- A list of files `docker build` leaves out of the build, such as `.git` and local `*.db` files.
A
- Allocation
- Memory a program asks for while running, which the garbage collector must later clean up. `-benchmem` shows B/op, the bytes allocated per run, and allocs/op, the number of allocations per run.
- atomic.Int64
- A counter that many goroutines can add to and read safely at the same time. The tests use it to count successful orders and server calls.
B
- Benchmark
- A test that times code. It is named `BenchmarkXxx`, takes a `*testing.B`, and runs its body inside `for b.Loop()`.
- benchstat
- A tool that compares benchmark runs properly, because timings vary from run to run.
- Blank import
- `import _ "path"` imports a package only for its side effect. The SQLite driver and `net/http/pprof` work this way.
- Build cache
- Docker's saved layers, reused when a step's inputs haven't changed. Copying `go.mod` before the source means a code change doesn't download every module again.
- Busy timeout
- How long SQLite waits for a lock before failing with `database is locked`. Kettle & Crane's `Open` sets 5,000 ms.
C
- cgo
- The way Go code calls C code. A program that uses cgo needs C libraries where it runs, and `CGO_ENABLED=0` makes Go use pure-Go versions instead.
- Closure
- A function written inline that can use variables from the code around it. In `PlaceOrder`, the function passed to `withTx` uses `o` and `lines` this way.
- cmp.Or
- A Go function that returns the first of its arguments that isn't empty (the zero value). It is commonly used to give a setting read from an environment variable, such as `DB_PATH` or `ADDR`, a default.
- Commit; rollback
- A commit makes a transaction's changes permanent; a rollback undoes all of them. `defer tx.Rollback()` undoes everything if the work fails, and does nothing after a commit.
- Connection pool
- A set of open database connections handed out as needed and shared by many goroutines. A `*sql.DB` is one, so you open one and share it.
- Container
- A running copy of an image, kept apart from other programs. One image can run many containers.
- COPY
- A Dockerfile instruction that copies files into the image. `COPY --from=build` takes a file from an earlier stage, and `--chown` sets who owns it.
- CPU profile
- A record of which functions were running, sampled about 100 times a second. It shows where a program spends its time.
- Cross-compiling
- Building a binary for another operating system or processor by setting `GOOS` and `GOARCH`, such as `GOOS=linux GOARCH=arm64` for an ARM server.
- curl
- A command-line tool for sending HTTP requests and showing the responses. It is used to call web services such as the rates and order services from a terminal.
D
- Data race
- Two goroutines using the same memory at once, with at least one writing. `go test -race` runs tests with the race detector, which finds them.
- Data source name (DSN)
- The string that tells a driver which database to open and how. For SQLite it is the file's path, optionally followed by options such as `_pragma=` settings.
- database/sql
- Go's standard package for SQL databases. The same code works for any database through a driver.
- db.ExecContext
- Runs SQL that returns no rows, such as the schema or an UPDATE. It returns an `sql.Result` and an error.
- db.QueryContext
- Runs a query that returns many rows as a `*sql.Rows`. You step through it with `rows.Next()`, read each row with `rows.Scan`, check `rows.Err()` afterward, and `defer rows.Close()`.
- db.QueryRowContext
- Runs a query expected to return one row. You chain `Scan` onto it, and it gives `sql.ErrNoRows` if nothing matched.
- Docker
- A tool that packages a program into an image so any machine with Docker runs it the same way. Docker Desktop is the app for Windows, macOS and Linux, free for personal use, education and small businesses (as of October 2026).
- docker build
- Runs a Dockerfile's steps to make an image, with `-t` naming it with a tag, as in `kettle/ratesvc:1.4.0`.
- Docker Hub
- The public registry where images such as `golang:1.27` are stored for download.
- docker logs
- Prints what a container's program wrote to standard output and standard error, so `slog` lines need no log files.
- docker run
- Starts a container from an image. `-d` runs it in the background, `--rm` removes it when it stops, `--name` names it, `-p` publishes a port, `-e` sets an environment variable and `-v` mounts a volume.
- docker stop
- Sends SIGTERM to a container's program and kills it if it hasn't exited after 10 seconds. `docker rm` then deletes the stopped container.
- Dockerfile
- A text file of steps that builds an image.
- Driver
- The package that talks to one kind of database for `database/sql`. Kettle & Crane uses a pure-Go SQLite driver, `ncruces/go-sqlite3`.
- Dynamically linked
- A binary that loads system libraries when it starts, so it needs them where it runs. A statically linked one doesn't.
E
- ENTRYPOINT; EXPOSE
- Dockerfile lines. `ENTRYPOINT` is the command a container runs, and `EXPOSE` notes which port the service listens on.
- ENV
- A Dockerfile line that bakes environment variables into the image, such as `DB_PATH` and `ADDR`. `docker run -e` can still override them.
- Environment variable
- A named setting passed to a program from outside, such as `ADDR`, `DB_PATH` or `RATES_URL`. It lets the same program run in different places without code changes.
- errgroup
- A helper that runs several goroutines together and waits for them all. If one returns an error, the shared context is canceled, as when the server goroutine fails and the shutdown goroutine should stop too.
- errors.As
- Looks through an error and anything it wraps for one of a given type, such as a `*StatusError` or `*StockError`, and gives you access to its fields.
- errors.Is
- Checks whether an error is, or wraps, a particular error value such as `sql.ErrNoRows` or `ErrNotFound`. It sees through `%w`.
- errors.Join
- Combines several errors into one. `check` uses it so a café hears about every problem with an order at once.
- Exponential backoff
- Waiting twice as long after each failed attempt, such as 100 ms, 200 ms, then 400 ms. It stops a retrying client from hammering a struggling server.
F
- file
- A command (on Linux and macOS) that describes a binary, such as whether it is statically or dynamically linked and which OS it was built for.
- Flame graph
- A picture of a profile in which each bar is a function, with the functions it called beneath it, and a bar's width is its share of the time.
- flat; cum
- The two time columns in pprof output. Flat is time in the function itself; cum also counts the functions it called.
- foreign_keys
- An SQLite pragma, set as `foreign_keys(1)`, that makes the database check `REFERENCES` links, such as an order line pointing at a real order.
- FROM
- A Dockerfile line that starts a build stage from a base image, such as `FROM golang:1.27 AS build` or the empty `FROM scratch`.
- Fuzzing; fuzz test
- Fuzzing lets Go invent many odd inputs from your samples to find one that breaks your code. A fuzz test is a `FuzzXxx(f *testing.F)` function that checks rules that must always hold.
G
- Garbage collector
- The part of Go's runtime that frees memory the program no longer uses. Lots of allocation gives it more work.
- go get
- `go get` downloads a package such as the SQLite driver and adds it to `go.mod`, the module's dependency list. `go.sum` holds checksums, and `go mod download` fetches all dependencies.
- go tool pprof
- Go's profile reader. `-top` lists the busiest functions, `-sample_index=alloc_space` reads memory profiles by bytes, and `-http` opens a browser view with a flame graph.
- go tool trace
- A Go tool that shows what every goroutine did over time, helping to find scheduling delays and concurrency problems.
- go version -m
- Shows what Go version and build settings a binary was built with, without running it, such as the `-ldflags` and `CGO_ENABLED` used.
- goose
- A migration tool that changes a database's tables over time. You need one because `CREATE TABLE IF NOT EXISTS` never changes an existing table.
- Graceful shutdown
- Stopping a server by letting requests in progress finish before it exits. `srv.Shutdown` with a timeout does this when a signal such as SIGTERM arrives.
- Guarded update
- An `UPDATE` whose `WHERE` also checks a condition, such as `AND stock >= ?`. It checks and changes the stock in one step, so Kettle & Crane can't oversell the last decaf.
H
- Handler
- A function `func(w http.ResponseWriter, r *http.Request)` that answers one kind of request. `http.HandlerFunc` turns a plain function into a handler.
- Host addresses (127.0.0.1, 0.0.0.0)
- 127.0.0.1 (`localhost`) is the machine itself, reachable only from that machine; 0.0.0.0 (or an address with no host, like `:8081`) listens on every network interface. Inside a container, `localhost` is the container, so a published port needs `:8081`.
- HTTP status codes
- Three-digit codes in an HTTP reply: 200 OK, 201 Created (new order), 400 Bad Request (bad input), 404 Not Found, 409 Conflict (too little stock), 429 Too Many Requests (slow down), 500 server error, and 502 Bad Gateway (a service we depend on failed). 4xx means the request itself is wrong, so retrying won't help; 5xx and 429 may pass and are worth a retry.
- http.Client
- The Go type for sending HTTP requests. `http.DefaultClient` never times out, so you make your own with `Timeout` set and reuse it.
- http.NewRequestWithContext
- Builds an HTTP request tied to a context. `Do` sends it, `resp.StatusCode` must be checked yourself, and `defer resp.Body.Close()` keeps connections from piling up.
- http.Server
- The Go type that serves requests. `ListenAndServe` serves until it fails, and after `Shutdown` it returns `http.ErrServerClosed` as the normal result.
- httptest.NewServer
- Starts a real server on a free local port for tests. `srv.URL` is its address and `srv.Client()` a client set up for it.
I
- Idempotency key
- A unique ID sent in a header so a server can spot and ignore a repeated request. It makes retrying a POST that places an order safe.
- Idempotent
- Safe to repeat: doing it twice has the same effect as once. A GET is idempotent, but a POST that places an order isn't.
- Image
- A packaged file system plus the command to start: everything the program needs and nothing from your machine.
- Immediate transaction
- An SQLite transaction that takes the write lock at `BEGIN`. Two writers then can't both read and then clash.
- iter.Pull
- A Go function that turns an iterator into a "give me the next one" function, so code can fetch values one at a time instead of using a `range` loop.
- iter.Seq[V]; iter.Seq2[K, V]
- The iterator types from package `iter`, giving one or two values per step. `iter.Seq2` is used for rows, yielding a product and an error.
- Iterator
- A function you can `range` over, shaped `func(yield func(V) bool)`. It hands out values one at a time, so a big table never sits in memory at once.
J
- Jitter
- A small random extra wait added to each retry. It stops many clients from retrying at the same moment.
K
- Keep-alive
- Keeping a connection open for the next request. A reused `http.Client` does this between calls.
- kill
- A command that sends a signal to a program by process ID, the system's number for a running program. `kill -TERM $!` asks the last background program to stop cleanly.
L
M
- math/rand/v2
- Go's package for random numbers. `rand.N(n)` returns one from 0 up to but not including `n`, and works on a `time.Duration`, which is how jitter is added.
- Memory profile
- A record of where a program allocated memory.
- Multi-stage build
- A Dockerfile that builds in one image and copies only the result into another. The Go toolchain stays behind, so the final image is tiny.
- Mux
- `http.ServeMux`, the router that sends each request to a handler by its pattern, such as `GET /orders/{id}`.
N
- net/http/pprof
- A package imported for its side effect that serves profiles under `/debug/pprof/`. Keep it on `localhost`, never exposed to the internet.
- Non-root
- Running as an ordinary user, not the all-powerful root. The Dockerfile's `USER 65534:65534` does this, so a break-in can't change the program.
- ns/op
- Nanoseconds per run of a benchmark. About 442,090 ns/op is roughly 0.44 ms per receipt.
O
- OR IGNORE
- SQLite syntax that skips rows whose primary key already exists. It makes running the seed twice safe.
- os.Exit
- A Go function that ends the program at once with a status code, where non-zero means failure. It skips deferred calls, so anything that needs closing, such as a database, must be closed by hand before calling it.
P
- Placeholder
- A `?` in SQL where a value goes, with the value passed separately so the driver sends it as data, never as SQL. It prevents SQL injection.
- Pragma
- An SQLite setting for one connection, such as `busy_timeout` or `journal_mode`. The driver applies `_pragma=` options in the DSN when it connects.
- Profile
- A record of where a program spends time or memory. A benchmark says how slow; a profile says where.
- Publish (a port)
- Forward a port on your machine into a container, as `-p 8080:8080` does. The server inside must listen on all interfaces, such as `:8081`, not `localhost`.
Q
- Query string
- The `?carrier=USPS&items=3` part of a URL. `net/url`'s `url.Values` builds it and `Encode()` escapes special characters, so you never paste raw values into a URL.
R
- Registry
- A store of images, such as Docker Hub, for downloading and sharing them.
- Retry
- Trying a failed call again, but only when there was no reply, or a 5xx or 429, and only for idempotent requests. Cap the attempts and wait between them.
- Retry-After
- An HTTP reply header, in seconds, that tells a client how long to wait before retrying, often with a 429.
S
- Scan
- Copies a row's columns into the variables you point it at, such as `&p.SKU`. On a single-row query it returns `sql.ErrNoRows` when nothing matched.
- scratch
- Docker's empty image: no shell, no tools, no files. A static Go binary runs in it, which keeps the image tiny.
- Seed corpus
- The sample inputs a fuzz test starts from, added with `f.Add`. Plain `go test` runs only these seeds.
- select (waiting with ctx.Done)
- A `select` waits for whichever of several channels is ready first. Retries use it on `time.After` and `ctx.Done()`, so a canceled request stops waiting at once.
- Sentinel error
- A package-level error value, such as `ErrNotFound`, that callers compare with `errors.Is`. The API turns `ErrNotFound` into a 404 and `ErrInvalid` into a 400.
- Signal; SIGTERM
- A signal is a short message the operating system sends a program. SIGTERM is the one that asks it to finish and exit, sent by `docker stop`, and `signal.NotifyContext` gives a context canceled on Ctrl+C or SIGTERM.
- slices and maps iterator helpers
- Functions that make and consume iterators. `All`, `Values` and `Keys` produce them, and `Collect` and `Sorted` turn them into slices.
- slog
- Go's structured logging package. The rates service writes text lines and the order service writes one JSON object per line.
- SQL injection
- An attack that slips SQL into a query built from input, such as typing `x' OR '1'='1` so every row matches. Placeholders prevent it.
- sql.ErrNoRows
- The error `Scan` returns when a one-row query found no row. `GetProduct` turns it into `ErrNotFound`.
- sql.Null[T]
- A value that may be NULL. `.V` holds it and `.Valid` says whether it was set, so `MAX` over no rows gives `Valid` false.
- sql.Open
- Takes a registered driver name and a DSN and returns a `*sql.DB` pool, but doesn't connect. `db.PingContext` actually connects, creating the SQLite file if needed.
- sql.Result
- What `ExecContext` returns. `LastInsertId()` is the id SQLite chose for a new row and `RowsAffected()` counts the rows an UPDATE or DELETE changed.
- SQLite
- A database that is one file, used here through a pure-Go driver. The `sqlite3` shell lets you query the file by hand.
- Static binary
- A program that needs no system libraries to run, so it works in an empty container. Build one with `CGO_ENABLED=0`.
- StockError
- A custom error type with `SKU`, `Have` and `Want` fields. It is returned when an order asks for more stock of a product than is left.
- strings.Builder
- Builds a string piece by piece in one growing buffer, without copying the whole thing each time, as `+=` does. It made Priya's `Receipt` about 12 times faster.
- Subtest; table test
- `t.Run(name, f)` runs one case on its own. A table test loops over a slice of cases, each as a subtest with its own fresh database.
T
- t.TempDir; t.Cleanup; t.Helper; t.Context
- Test helpers: a new empty folder deleted when the test ends, code to run when it ends, a mark so failures point at the test's line, and a context canceled when it ends.
- Tag
- The part of an image name after the colon, usually a version, as in `kettle/ratesvc:1.4.0`.
- testdata/fuzz
- The folder where Go saves inputs that made a fuzz test fail. Plain `go test` replays them, so the bug can't quietly return, and you commit them with your code.
- testing.Short; t.Skip
- `go test -short` asks tests to skip slow work, which they check with `testing.Short()`. `t.Skip` ends a test as skipped, not failed.
- time.After
- Returns a channel that receives a value once a duration has passed. Paired with `ctx.Done()` in a `select`, it waits between retries but stops at once if the request is canceled.
- Timeout (client)
- `http.Client{Timeout: d}` limits a whole call. A context deadline can make it shorter, and the error then ends in `context deadline exceeded`.
- Transaction
- A group of changes that succeed or fail together, with other connections seeing nothing until the commit. `db.BeginTx` starts one and returns a `*sql.Tx`.
U
- User-defined network
- A Docker network, made with `docker network create`, on which containers started with `--network` reach each other by name, such as the orders container reaching `http://rates:8081`.
V
- Version stamp
- A string set at build time with `-X main.version=...` so a running program can report which version it is.
- Volume
- Storage Docker keeps outside any container, mounted with `-v`. It keeps the SQLite file safe when the container is removed.
W
- WaitGroup
- Lets a test start many goroutines and wait for all of them to finish. `wg.Go` starts one and `wg.Wait` waits.
- WAL
- Write-ahead log: an SQLite mode where readers and the writer don't block each other.
- Wrapping errors with %w
- Using `%w` in `fmt.Errorf` keeps the original error inside the new one, so `errors.Is` still finds it. A single `Errorf` may hold two `%w` verbs.
Y
- yield
- The function an iterator calls to hand the loop each value. It runs the loop body once and returns `false` after a `break`, and the iterator must then return at once.