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 1 of 2Go 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.