maps

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 2 Imported by: 1

README

maps

Generic free functions over plain Go maps: Equal/NotEqual (value comparison), Keys/Values (extract slices), and KeysSorted. Part of rosetta.

This is the map analogue of slice; for typed map values with accessors, see mapof.

What matters here

  • Keys and Values return results in map-iteration order, which Go randomizes — they do NOT sort. If you need deterministic output (for comparison, display, or golden tests), use KeysSorted. Reaching for Keys and expecting stable order is a silent flakiness bug.
  • Equal compares values with ==, so the value type is constrained to comparable. It is not a deep/reflect comparison — maps of slices or maps of maps are out of scope.

Documentation

Overview

Package maps provides utility functions for working with Go maps: Keys, KeysSorted, Values, and the Equal/NotEqual comparisons.

It is the free-function counterpart to the mapof package. Use these on maps you already have; use mapof when you want a map type that carries typed accessors and can be addressed by the schema package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal added in v0.24.8

func Equal[T comparable](map1 map[string]T, map2 map[string]T) bool

Equal returns TRUE if the two maps are identical, having the same items in the same order, with no alterations.

func Keys added in v0.22.0

func Keys[T cmp.Ordered, U any](value map[T]U) []T

Keys returns all keys of a map

func KeysSorted added in v0.22.0

func KeysSorted[T cmp.Ordered, U any](value map[T]U) []T

KeysSorted returns all keys of a map, sorted

func NotEqual added in v0.24.8

func NotEqual[T comparable](map1 map[string]T, map2 map[string]T) bool

NotEqual returns TRUE if the two maps are NOT identical

func Values added in v0.25.34

func Values[T cmp.Ordered, U any](value map[T]U) []U

Values returns a slice of all values of a map

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL