Documentation
¶
Overview ¶
Package iterutil contains determinism-safe iteration helpers.
Go's map iteration order is randomized. Any code that drives output, logging, error reporting, hashing, cache keys, or downstream ordering from a map range produces non-deterministic results across runs.
This package centralizes the "sort then iterate" pattern so authors can opt into determinism explicitly via a single helper, and so a linter (forbidigo or similar) can ban bare `range map[K]V` in determinism-sensitive packages and steer callers here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForEachSorted ¶
ForEachSorted invokes fn(key, m[key]) for each key in m, in ascending key order. Callers should prefer this over a bare `for k, v := range m` in any code path that affects observable output, logs, errors, or hashes.
func SortedKeys ¶
SortedKeys returns the keys of m in ascending order.
The returned slice is freshly allocated; callers may freely mutate it. For empty maps the returned slice is nil.
Types ¶
This section is empty.