Glossary

Updated

September 13, 2026

Glossary

Short definitions for words this book uses with a fixed meaning. If a chapter taught a default, that default is in the definition.

alignment. The address multiple a type prefers. int64 wants 8-byte alignment on 64-bit. Padding in a struct exists to satisfy it. See unsafe.Sizeof in the unsafe chapter — as a ruler, not as a licence.

benchmark. A function BenchmarkXxx(*testing.B) run by go test -bench. Reports ns/op. -benchmem adds bytes and allocs per op.

build constraint (build tag). A //go:build line that includes or excludes a file. //go:build ignore keeps a go generate helper out of the package.

cgo. The bridge that lets a Go file import "C" and call C. Needs a C compiler. Breaks easy cross-compiles. Avoid unless you must.

channel. A typed pipe between goroutines. Send ch <- v, receive v := <-ch. Buffer size is set at make. Close only from the sender side.

compatibility promise. For the standard library: exported signatures stay. For your module: behave the same, or bump a major version (/v2).

constructor. An exported function (Open, New) that returns a valid value. Prefer this over exported struct fields that callers fill in.

context. context.Context carries cancellation, a deadline, and optional request values down a call chain. The first argument of an RPC-shaped function.

coverage. The fraction of statements go test -cover saw run. A number, not a goal of 100%.

embed (//go:embed). Compiler feature that bakes a file into a string, []byte, or embed.FS at build time. Import "embed" or _ "embed".

error. A value that implements error. Returned, wrapped with %w, inspected with errors.Is / errors.As. Not an exception.

escape analysis. The compiler’s decision that a value must live on the heap (it “escapes”) because a pointer to it outlives the stack frame. go build -gcflags=-m prints the decisions.

example test. ExampleXxx in a _test.go file. // Output: makes go test compare stdout. Shows up in go doc.

exported. A name that starts with a capital letter. Visible from other packages. Part of your API.

fuzz. FuzzXxx(*testing.F) — the testing tool feeds random inputs that still satisfy your seed corpus.

garbage collection (GC). Automatic reclaim of heap values that nothing points to. You still close files and stop goroutines; GC does not.

generate (go generate). Runs //go:generate commands. Not part of go build. Prefer a go run helper you own.

go.mod. The file that names a module and its Go version and requirements.

goroutine. A function the runtime can run concurrently. Started with go f(). Cheap compared to an OS thread. Not magic: you still need to wait, cancel, or deadlock.

govulncheck. Tool that matches your module graph (and call graph) against the Go vulnerability database.

interface. A set of methods. Satisfied implicitly: no implements keyword. Keep it small. Define it where it is used, when you have two real implementations.

iter.Seq / iter.Seq2. Type aliases for push-iterator functions (Go 1.23+). iter.Seq[V] is func(yield func(V) bool); iter.Seq2[K, V] adds a key. range can iterate over them. slices.Collect and maps.Collect drain them into slices and maps.

ldflags -X. Linker flag that overwrites a package-level string at build time. Used to stamp version.

maps package. "maps" (Go 1.21+) provides generic functions over map values: maps.Clone, maps.Copy, maps.Keys, maps.Values, maps.Equal, maps.DeleteFunc. Everything you used to write with a for range.

method. A function with a receiver. func (t Ticket) Label() string. Value receiver copies; pointer receiver can mutate.

module. A versioned unit of source with a go.mod and an import path (example.com/desk). Contains one or more packages.

mutex. sync.Mutex (or RWMutex) for shared memory. Lock, copy of a mutex is a vet finding, unlock. Prefer channels when they fit.

package. A directory of Go files with the same package name. The import path is module path plus directory.

panic / recover. Abort the goroutine; recover only in defer. Not for ordinary errors.

pprof. Profiler shipped as go tool pprof. CPU and memory profiles from tests or net/http/pprof.

pointer. Address of a value. *T. Nil is the zero value. Do not share mutable pointers across goroutines without a lock or a single owner.

race detector. go test -race. Finds unsynchronised shared memory. Use it in CI.

reflection (reflect). Run-time inspection of types and values. Last resort. fmt and encoding/json already do the usual jobs.

slice. Header (pointer, length, capacity) plus a backing array. append may allocate a new array.

slices package. "slices" (Go 1.21+) provides generic functions over slices: slices.Sort, slices.SortFunc, slices.Contains, slices.Index, slices.BinarySearch, slices.Compact, slices.Reverse, slices.Clone, slices.Collect. Prefer over hand-written loops.

range-over-function. Since Go 1.23, range accepts a function with signature func(yield func(V) bool) or func(yield func(K, V) bool). The runtime calls the function; the function calls yield per element; break causes yield to return false. See iter.Seq / iter.Seq2.

staticcheck. Optional extra static analyser. Not part of the go binary.

stringer. A common generator for String() methods. This book prefers a hand-written String or a tiny go generate helper.

table test. A slice of cases in a TestXxx function, looped with t.Run.

toolchain. The go command: run, build, test, vet, fmt, doc, mod.

unsafe. Package that can break the type system. This book uses unsafe.Sizeof as a ruler. unsafe.Pointer is a contract with the compiler; do not take it.

vet (go vet). Static checks that ship with Go. Wrong Printf verbs, copied locks, and similar. Run with tests.

workspace (go.work). A file that lists modules you are editing together. Local replace without publishing.

zero value. The value of a declared variable with no initialiser: 0, "", nil, struct of zeros. Useful when it is a valid empty; dangerous when it is not (then use a constructor).

CGO_ENABLED. 0 skips the C compiler. Boring default for pure Go. 1 is required for cgo.

GOOS / GOARCH. Target OS and architecture for go build. Cross-compilation for pure Go is these two variables.