Go guides
Every published Go guide, newest first, with practical examples you can copy into your own project.
3,815 guides across 14 topics
Topics
Popular Go guides
Most readLatest Go guides
Page 2 of 2Go Maps: Hash Map Internals, Concurrency Safety, and delete Operations
Nil map semantics, comparability rules for keys, concurrent access that kills the process, non-addressable values, and growth that never shrinks.
Go defer, panic, and recover: Control Flow, Resource Cleanup, and Pitfalls
Deferred calls run LIFO with arguments captured at the defer, recover only works in the panicking frame's deferred function, and defer inside a loop leaks until the function returns.
Go Slices vs Arrays: Slice Header, Length, Capacity, and append Mechanics
The three-word slice header, why append sometimes writes into another slice's memory, how the three-index slice prevents it, and where capacity hints and clearing matter.
Go sync Package: Mutex, RWMutex, WaitGroup, and sync.Once Explained
The primitives that make shared memory safe in Go, the reentrancy and copying traps that break them silently, and when sync.Once or sync.Cond beats a plain mutex.
Go Generics: Type Parameters, Constraints, any, and comparable
Type parameter syntax, what the tilde in a constraint union actually admits, where inference stops, and why a struct containing a slice cannot satisfy comparable.
Go Context: Cancellation, Deadlines, Timeouts, and Context Values
How context cancellation propagates down a call tree, why every CancelFunc must be called, how deadlines negotiate with parents, and what belongs in a context value.
Go Structs and Pointers: Value vs Pointer Receivers, Embedding, and Memory
Value and pointer receivers, shallow copies, addressability, embedding, and struct layout: the rules that decide when a method mutates, when a copy diverges, and why field order changes size.
Go Error Handling: errors.Is, errors.As, Sentinel Errors, and Custom Types
errors.Is and errors.As explained through the wrapping that makes them necessary: %w chains, multiple wrapped errors, custom Is methods, and the pointer rules that make As panic.
Go Interfaces: Implicit Implementation, Type Assertions, and Type Switches
Implicit interface satisfaction in Go: method sets and receiver kinds, type assertions versus type switches, the typed-nil interface, and the compile errors that name the missing method.
Go Goroutines and Channels: Concurrency Patterns, Buffered Channels, and select
Go concurrency from the channel up: what an unbuffered send waits for, how select chooses, why goroutines leak, and the worker pool, timeout, and fan-in patterns that prevent it.