All articles
25 articles
-
Represent and transform data safely
Remove Duplicate Values from a Go Slice Without Losing First-Seen Order
Use a map-backed pass to keep the first occurrence of each comparable value, an equality function for other values, or sorting and compacting when order can change.
-
Represent and transform data safely
Find an Element in a Go Slice with `slices.Index` or a Loop
Use `slices.Index` for the first matching position, `slices.Contains` for membership, and a loop when a predicate defines the match.
-
Represent and transform data safely
Sum Values in a Go Slice with a Loop or `slices.Reduce`
Use a range loop for a straightforward `[]int` total, or a third-party reducer when the callback makes a more varied calculation easier to express.
-
Represent and transform data safely
Find the Maximum in a Go Slice Without Sorting It
Find the largest value in a Go slice with a one-pass loop or slices.Max, while making empty-input behavior explicit.
-
Represent and transform data safely
Sort a Go Slice Descending with sort.Slice or sort.Interface
Use sort.Slice for a one-off descending comparison, or define sort.Interface when the ordering is worth reusing.
-
Verify behavior and measure performance
Go 1.27 SIMD: Vectorize a Go Loop, Then Measure Whether It Pays
Use Go 1.27’s experimental portable SIMD API for an in-place subtraction loop, check every tail length, and benchmark it against scalar Go.
-
Represent and transform data safely
Go Interface to String: When to Assert and When to Format
Use a type assertion to retrieve a string held by an interface, or fmt to produce a textual representation of another value.
-
Verify behavior and measure performance
How to Benchmark Go vs. Python Fairly: A Reproducible Method
Compare equivalent work, measure the metric behind your decision, and record enough about the setup to explain both results and surprises.
-
Set up and maintain Go projects and tooling
How to Download Go Module Dependencies and Use the Module Cache
Run a test to fetch dependencies it needs, use go mod download to prefetch modules, and inspect the cache location with go env.
-
Represent and transform data safely
Go Interfaces and Pointer Receivers: Does the Struct or Its Pointer Implement It?
If an interface requires a pointer-receiver method, pass a pointer to the struct: the struct value itself does not satisfy that interface.
-
Build HTTP services and handle external dependencies
Download a URL to a File in Go: Check HTTP Errors and Avoid Partial Output
Stream an HTTP response to a caller-chosen path without saving error pages or leaving a partial download at that path.
-
Build HTTP services and handle external dependencies
Go 1.27 UUIDs: What to Check Before Dropping google/uuid
Go 1.27 is reported to add UUID generation and parsing, but replacing a dependency still requires checking the final package API and your supported toolchains.
-
Represent and transform data safely
How to Merge Two Maps in Go
Merge Go maps with a loop or maps.Copy, choose whether to mutate an input, and understand when generics or mergo better fit the job.
-
Represent and transform data safely
How to Use Sets in Go with mapset and Map-Based Sets
Use map[T]struct{} for lightweight membership checks, or mapset v2 when you need typed set operations and a concurrency-oriented implementation.
-
Represent and transform data safely
How to Clone a Map in Go Without Sharing the Underlying Values
Learn when maps.Clone is enough, why reference-valued entries still alias, and how to write a true deep copy for maps containing slices.
-
Represent and transform data safely
How to Implement Enums in Go with iota and Typed Constants
Use a named integer type, typed constants, iota, String methods, and explicit validation to build practical enum-like values in Go.
-
Control work with cancellation and bounds
Using context.Context in Go: Cancellation, Timeouts, and Request-Scoped Values
Learn how to propagate cancellation and deadlines through Go code, clean up derived contexts, and avoid common API design mistakes.
-
Represent and transform data safely
Go Slices: What append, copy, and cap Actually Do to the Underlying Array
Learn how Go slice length, capacity, aliasing, append, and copy determine whether operations reuse or replace the underlying array.
-
Represent and transform data safely
Go Generics: How to Write Type Parameters, Constraints, and Generic Interfaces
Learn how Go type parameters are instantiated, how to choose constraints, and how to build generic functions, types, and interfaces.
-
Verify behavior and measure performance
Running and Testing Go Snippets with the Go Playground
Use the Go Playground to run small programs and tests in a browser while accounting for its fixed clock, restricted I/O, and resource limits.
-
Set up and maintain Go projects and tooling
Install the Go Toolchain and Configure PATH, GOROOT, and GOPATH on Linux, macOS, and Windows
Install Go using the standard installer for your platform, configure PATH, verify the selected binary, and initialize a module for your first project.
-
Represent and transform data safely
Go for Loops: Range Semantics and Loop Variable Capture Before and After Go 1.22
Understand how Go 1.22 module boundaries change captured loop variables, how older code behaves, and how to make captures safe in earlier modules.
-
Set up and maintain Go projects and tooling
Managing Go Versions and Toolchains Across Projects
Use Go 1.21 or newer to declare each module’s minimum language version and let the go command select the toolchain requested by that project.
-
Represent and transform data safely
Using Maps in Go: Declarations, Lookups, and Iteration
Learn how to initialize Go maps, distinguish missing keys from zero values, delete entries, and iterate without relying on order.
-
Set up and maintain Go projects and tooling
Set Up and Configure golangci-lint for a Go Project
Install a known golangci-lint release, create a v2 configuration, verify enabled linters, and keep local and CI commands aligned.

























