Go Glossary
41 terms — key concepts, keywords, and idioms in the Go programming language.
A
- atomic
- Package sync/atomic provides low-level atomic memory primitives for integers and pointers, enabling lock-free concurrent operations.→ See lesson
B
- blank identifier
- The underscore (_) is the blank identifier; it discards values without allocation and suppresses unused-variable errors.→ See lesson
- build tag
- A build tag (//go:build ...) is a compiler directive that conditionally includes or excludes a source file based on OS, architecture, or custom conditions.→ See lesson
C
- channel
- A channel (chan T) is a typed conduit for sending and receiving values between goroutines, enabling safe concurrent communication.→ See lesson
- closure
- A closure is a function value that captures variables from its surrounding scope, carrying state across calls.→ See lesson
- composition
- Composition in Go is the practice of building complex types by combining simpler ones via struct embedding instead of inheritance.→ See lesson
- context
- The context.Context type carries deadlines, cancellation signals, and key-value pairs across API boundaries and goroutines.→ See lesson
D
- defer
- A defer statement schedules a function call to run immediately before the surrounding function returns, executing in LIFO order.→ See lesson
E
- embedding
- Struct embedding promotes another type's fields and methods into the enclosing struct, enabling interface implementation through composition.→ See lesson
- error
- error is a built-in interface with a single Error() string method; functions signal failure by returning a non-nil error as their last value.→ See lesson
- exported / unexported
- Identifiers starting with an uppercase letter are exported (public); lowercase identifiers are unexported and accessible only within the same package.→ See lesson
G
- go directive
- The go directive in go.mod (e.g., go 1.22) declares the minimum Go toolchain version and enables version-specific semantics.→ See lesson
- go.sum
- go.sum records the expected cryptographic checksums of module content, ensuring reproducible and tamper-proof dependency downloads.→ See lesson
- GOMODCACHE
- GOMODCACHE is the directory where Go stores downloaded module source code and metadata; defaults to $GOPATH/pkg/mod.→ See lesson
- GOPATH
- GOPATH was the workspace root for Go projects before modules; it now mainly hosts the module download cache and installed binaries.→ See lesson
- GOROOT
- GOROOT is the directory containing the Go installation — compiler, linker, and standard library source code.
- goroutine
- A goroutine is a lightweight, concurrently executing function managed by the Go runtime; start one with the go keyword before a function call.→ See lesson
I
- init
- An init() function runs automatically before main(); a package can have multiple init functions, all of which execute in source order.→ See lesson
- interface
- An interface defines a set of method signatures; any type that implements all those methods satisfies the interface implicitly.→ See lesson
- iota
- iota is a pre-declared identifier that generates an incrementing integer sequence within a const block, resetting to 0 at each const keyword.→ See lesson
M
- map
- A map (map[K]V) is Go's built-in hash table; initialise with make or a literal before writing to avoid a nil-map panic.→ See lesson
- method
- A method is a function with a receiver parameter, associating behaviour with a named type (struct or any other named type).→ See lesson
- module
- A module is a collection of Go packages versioned together; it is defined by a go.mod file at the root of the module tree.→ See lesson
- Mutex
- sync.Mutex is a mutual-exclusion lock; Lock() blocks until the mutex is acquired, and Unlock() releases it, protecting shared data from concurrent access.→ See lesson
N
- nil
- nil is the zero value for pointers, channels, functions, interfaces, maps, and slices; an interface is nil only when both its type and value are nil.→ See lesson
O
- Once
- sync.Once guarantees that a function is executed exactly once regardless of how many goroutines call Do concurrently.→ See lesson
P
- package
- A package is the basic unit of code organisation in Go; every source file belongs to a package declared with the package keyword.→ See lesson
- panic
- panic stops normal execution, unwinds the stack running deferred functions, and terminates the program unless recovered with recover().→ See lesson
- pointer
- A pointer (*T) holds the memory address of a value; use & to take an address and * to dereference it.→ See lesson
R
- range
- range iterates over arrays, slices, strings, maps, and channels, yielding index/key and value pairs in a for loop.→ See lesson
- receiver
- A receiver is the extra parameter before the function name in a method declaration, binding the method to a specific type.→ See lesson
- recover
- recover() is called inside a deferred function to stop a panic and return the value passed to panic, allowing graceful recovery.→ See lesson
- rune
- rune is an alias for int32 representing a Unicode code point; ranging over a string yields runes, while indexing gives raw bytes.→ See lesson
S
- select
- select blocks until one of its channel cases is ready, then executes that case; a default clause makes it non-blocking.→ See lesson
- slice
- A slice ([]T) is a dynamically-sized view into an underlying array, described by a pointer, length, and capacity.→ See lesson
- struct
- A struct is a composite type that groups named fields together; it is the primary way to define custom data types in Go.→ See lesson
T
- type assertion
- A type assertion (x.(T)) extracts the concrete value of an interface; the two-value form (v, ok) avoids a panic if the assertion fails.→ See lesson
- type switch
- A type switch compares an interface value's dynamic type against a series of types, similar to a regular switch but on types.→ See lesson
V
- variadic
- A variadic function accepts a variable number of arguments of the same type using the ... syntax (e.g., func sum(ns ...int)).→ See lesson
W
- WaitGroup
- sync.WaitGroup waits for a collection of goroutines to finish; Add increments the counter, Done decrements it, and Wait blocks until it reaches zero.→ See lesson
Z
- zero value
- Every variable in Go is automatically initialised to its zero value: 0 for numerics, false for booleans, "" for strings, and nil for reference types.→ See lesson