Pages

Topics

Tools

↑↓navigate↵openescclose

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

Latest Go guides

3D illustration of an immutable string byte slice decomposing into variable-width UTF-8 rune characters
Go

Go Strings, Runes, and Bytes: UTF-8 Encoding, Conversion, and Memory

Bytes versus runes, len that counts bytes, slicing that splits characters, Builder for linear concatenation, and normalization the standard library omits.

GoStringsUTF-8
3D illustration of channel ports polled by a central multiplexer with a default bypass and timeout timer
Go

Go select Statement: Non-Blocking Operations, Timeouts, and Nil Channels

Random choice among ready cases, non-blocking polls with default, nil channels that disable a case, timer reuse, and labeled breaks out of a loop.

GoConcurrencyControl Flow
3D illustration of a dependency tree running package init functions in topological order before main
Go

Go init Function: Package Initialization Order, Imports, and Side Effects

What runs before main, the order across imports and files, why init cannot return an error, and the sync.Once replacement that can be tested.

GoArchitectureRuntime
3D illustration of a Go struct converting bidirectionally into JSON streams through tagged field conduits
Go

Go JSON: Marshaling, Unmarshaling, Struct Tags, and Custom Parsers

Struct tags, omitempty that skips false and zero, custom marshalers without recursion, RawMessage for tagged unions, and float64 precision loss.

GoJSONSerialization
3D illustration of binary bit flags 1, 2, 4, 8 shifting upward with glowing iota counter increments
Go

Go iota: Enumerations, Bitmask Flags, and Constant Expressions

How iota advances per const line, typed enums with gaps, bit flags with 1 << iota, and the unit scale pattern that shifts with one blank line.

GoConstantsBitmask
3D illustration of a tabular test matrix running cases with green check badges and benchmark stopwatches
Go

Go testing Package: Unit Tests, Table-Driven Tests, and Benchmarks

Table-driven subtests, t.Parallel ownership, benchmark timers and allocations, cleanup order, golden files, and fuzzing with property checks.

GoTestingBest Practices
3D illustration of inner struct components embedded into an outer wrapper struct with promoted methods
Go

Go Struct Embedding: Composition over Inheritance and Method Shadowing

Promotion by depth, ambiguous selectors, embedded pointers that panic, why there is no virtual dispatch, and JSON flattening that drops shadowed fields.

GoCompositionStructs
3D illustration of an any value entering a multi-way type switch scanner that routes to concrete type tracks
Go

Go Type Switches: Syntax, Type Assertions, and Empty Interface Handling

Assertion forms that panic and those that do not, multi-type cases, typed nil interfaces, pointer-receiver method sets, and errors.As for wrapped errors.

GoInterfacesType System
3D illustration of a channel queue draining data packets through a range loop until closed safely
Go

Go Channels: Closing Channels, Range over Channels, and Idiomatic Patterns

Closing as a sender's statement, buffered values delivered after close, coordinating multiple senders, and the closed channel that spins a select loop.

GoConcurrencyChannels
3D illustration of struct method calls contrasting pointer mutations against isolated copied value blocks
Go

Go Methods: Value vs Pointer Receivers, Method Sets, and Expressions

Value and pointer receivers, the method sets they produce, why map elements cannot call pointer methods, and method values that capture a copy.

GoMethodsOOP