Skip to content
teach

Go Glossary

Canonical terms for this workspace. A term lands here once it can be used correctly, not when it is first mentioned, so this grows as lessons are earned.

Usage in this workspace

Two words mean something narrower in Go than they do in most other languages. Carrying the wider meaning across produces code that compiles and is still wrong, so both are pinned from the start:

Interface:
A set of method signatures that any type satisfies implicitly by having those methods. There is no declaration of intent and no implements.
Avoid: contract, abstract class, implements relationship

Zero value:
The usable default a variable holds when declared without initialisation: 0, "", nil, or a struct with each field at its own zero value. Designing types so the zero value works is idiomatic Go.
Avoid: null, undefined, uninitialised

Terms

Addressable:
A property of an expression that has a memory address, so &x is legal and a pointer method may be called on it. Variables and struct fields are addressable; map elements and function results are not.
Avoid: assignable, referenceable

Backing array:
The contiguous storage a slice points into. A slice does not own it, and two slices can share one without either knowing.
Avoid: underlying buffer, internal array

Channel:
A typed conduit that carries values between goroutines and establishes a happens-before edge in doing so. Unbuffered channels synchronise both sides; buffered ones decouple them.
Avoid: queue, pipe, stream

Context:
A value carrying a cancellation signal, a deadline and request-scoped metadata down a call tree. It is a parameter, never a struct field, and cancellation through it is cooperative.
Avoid: cancellation token, request scope, thread local

Data race:
Two goroutines accessing the same memory with at least one write and no happens-before edge between them. It is undefined behaviour, not an unpredictable-but-bounded outcome.
Avoid: race condition, which is the broader logical bug; a program can have one without a data race

Embedding:
Declaring a field with a type and no name, so the outer type promotes the embedded type's exported fields and methods. It is delegation the compiler writes for you, with no dynamic dispatch.
Avoid: inheritance, subclassing, extending

Escape analysis:
The compiler's proof about whether a value outlives the function that created it. A value that cannot be proven local escapes to the heap; everything else lives on the stack.
Avoid: heap allocation analysis, boxing

Goroutine:
An independently scheduled function call, multiplexed by the runtime onto operating-system threads, with a stack that grows on demand. It has no identity and no owner unless you give it one.
Avoid: thread, coroutine, task, green thread

Goroutine leak:
A goroutine blocked on something that can never happen, so the runtime can never collect it or anything its stack references.
Avoid: hung thread, zombie goroutine

Happens-before:
The ordering guarantee the memory model defines between two operations. Where it exists, one goroutine is guaranteed to observe the other's writes; where it does not, there is a data race.
Avoid: synchronised, ordered, sequenced

Method set:
The methods a type carries for the purpose of satisfying an interface. T has only its value-receiver methods; *T has both, which is why a value can fail to satisfy an interface its pointer satisfies.
Avoid: method list, vtable, type signature

Middleware:
A function from http.Handler to http.Handler, wrapping a handler with behavior that runs before, after, or instead of calling the wrapped handler. Composed by nesting, outermost first to see a request and last to see its response; not calling the wrapped handler on some path is how it rejects a request outright.
Avoid: assuming it always calls the next handler (an auth or validation middleware routinely writes a response and returns instead, on purpose)

Minimal version selection:
The rule that resolves a build to the highest of the minimum versions required across the module graph, rather than to the newest published version. It is what makes builds reproducible without a lockfile.
Avoid: dependency resolution, version pinning

Module:
A collection of packages released and versioned together, rooted at a go.mod. Major version 2 and above carries the version in the module path.
Avoid: library, artifact, project

Package:
A directory of .go files compiled together, and the unit of both encapsulation and naming. Identifiers starting with an uppercase letter are visible to importers; everything else is not.
Avoid: namespace, module, folder

Receiver:
The value or pointer a method is called on, declared between func and the method name. Choose value or pointer per type rather than per method.
Avoid: this, self, instance

RED method:
A request-driven service's three instrumentation signals: Rate, Errors, Duration, the last tracked as a percentile rather than an average so a slow tail is visible. Measures a service from the outside, the user's experience of it, complementary to the USE method's resource-level view.
Avoid: an average for duration (a mean is dragged toward the bulk of fast requests and can hide a real, painful slow tail entirely)

ResponseRecorder:
An http.ResponseWriter implementation from httptest.NewRecorder() that records a handler's writes for inspection instead of sending them over a network. Satisfies the interface implicitly, so a handler called with one runs its real logic with no listener and no port involved at all.
Avoid: httptest.NewServer for the same job (that starts a real, loopback server for testing an HTTP client, the reverse direction from testing a handler directly)

Rune:
An alias for int32 holding a Unicode code point. Ranging a string yields runes with their byte offsets; indexing a string yields a byte.
Avoid: character, char, symbol

Sentinel error:
A package-level error value that callers identify with errors.Is. Documenting one makes it part of your API.
Avoid: error constant, error code, marker error

Slice:
A three-word header (pointer, length, capacity) describing a view into a backing array. It is copied by value like everything else, which is why appending inside a function does not change the caller's length.
Avoid: list, array, vector

traceparent:
The W3C Trace Context header (00-{trace ID}-{span ID}-{flags}) OpenTelemetry adopted to correlate a request across services. A service preserves the trace ID on its outgoing calls but must generate its own new span ID for each hop; failing to forward the header at all silently starts a disconnected new trace downstream.
Avoid: forwarding the exact header unchanged (each hop needs its own span ID; only the trace ID stays constant across the whole request)

Transaction-per-test isolation:
Beginning a database transaction before a test runs and rolling it back in t.Cleanup instead of ever calling Commit, so nothing the test wrote is ever visible outside it and every test starts from the same known state. Schema migrations must run before this transaction begins, never inside it.
Avoid: committing inside a test meant to be isolated this way (a committed change persists across tests, defeating the whole point of the pattern)

Type parameter:
A placeholder type in a function or type declaration, bounded by a constraint. Worth introducing when the same logic is genuinely identical across types, not when behaviour differs. That is an interface.
Avoid: generic type, template parameter

USE method:
A resource's three instrumentation signals: Utilization, Saturation, Errors, checked from inside a system (a CPU, a disk, a connection pool) to find a bottleneck fast. Complementary to the RED method's outside-in, service-level view, not a competing choice.
Avoid: applying it to a whole request-driven service (USE is scoped to a resource; RED is the service-level counterpart)

Wrapping:
Producing an error that keeps another retrievable, with %w in fmt.Errorf or an Unwrap method. What you wrap becomes part of your API, because callers can match on it.
Avoid: chaining, nesting, causing

* Aliases marked with an asterisk are real terms with a different meaning, listed to keep the two apart rather than because the word is wrong.

Table of contents