Go
Go · Browse articles by tag (only tags with 5+ articles get a page).
Build a Command-Line Tool in Go
A line-counting CLI from scratch: flag parsing, reading files or stdin, bufio scanning with a raised buffer, exit codes, subcommands, and version injection with ldflags.
Build an HTTP Service in Go
A JSON API with only net/http: method-based routing, request decoding and validation, a single error shape, request ID and logging middleware, timeouts, graceful shutdown, httptest.
Context and Cancellation in Go
What context is for: Background versus TODO, WithCancel/WithTimeout/WithDeadline, ctx as the first parameter, select on Done, leaks, why it must not live in a struct.
Go Control Flow: if, for and switch
Why Go has exactly one loop, how the if initialiser keeps variables scoped, what switch does differently, and how range behaves over slices, maps and strings.
Go Functions and Error Handling
Multiple and named results, the error interface, wrapping with %w and inspecting with errors.Is and errors.As, plus where defer, panic and recover belong.
A Practical Introduction to Go Generics
Type parameters and constraints: any and comparable, custom constraints with ~, Map and Filter helpers, generic types, type inference, and when not to use generics.
Goroutines and Channels in Go
The concurrency primitives, used correctly: go with WaitGroup, buffered versus unbuffered channels, close and range rules, select and timeouts, worker pools, mutex versus channels.
Go Setup and Your First Program
Install Go 1.24, understand what GOPATH and module mode really mean, and get comfortable with go mod init, go run, go build, go fmt and go vet.
Go Interfaces and Composition
Implicit interface satisfaction, why small interfaces travel further, type assertions and type switches, the nil-interface trap, and composition over inheritance.
Go Maps and Structs
Declaring and populating maps, the comma-ok idiom, why nil maps panic on write, plus struct literals, exported fields, JSON tags and embedding.
Modules, Packages and Internal Boundaries in Go
How modules, packages and directories fit together: go.mod and go.sum, internal packages, exported identifiers, go get and go mod tidy, MVS, replace, vendor and cycles.
Go Pointers, Methods and Value Semantics
Address-of and dereference, new versus composite literals, value and pointer receivers, method sets and interface satisfaction, plus when a pointer is worth it.
Profiling Go with pprof
Capture CPU and heap profiles from benchmarks or a live server, read top, list and flame graphs, compare allocations, and keep /debug/pprof off the public internet.
Slices versus Arrays in Go
Arrays carry their length in the type and copy on assignment; slices are small descriptors over shared memory. Length, capacity and append aliasing explained.
Testing and Benchmarking in Go
Table-driven tests with the testing package: subtests, t.Helper and t.Cleanup, temp dirs, httptest, benchmarks with b.Loop, allocs/op, coverage and fuzzing.
Go Variables, Types and Zero Values
var versus :=, the zero-value design that removes uninitialised variables, constants and iota, and the boundaries between string, byte and rune.