maputils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

Maputils

Utilities for working with Go maps, providing functional transformations and map operations.

Features

  • Transformations - Map keys and values with custom functions
  • Merging - Join maps with configurable conflict resolution
  • Comparison - Check submap relationships with custom equality functions

All functions are generic and type-safe, supporting arbitrary key and value types.

Documentation

Overview

Package maputils provides utilities for working with Go maps, providing functional transformations and map operations.

See README.md for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSubMap

func IsSubMap[K comparable, V any](sub, super map[K]V, eq func(a, b V) bool) bool

IsSubMap checks if the 'sub' map is a submap of the 'super' map using the provided equality function for values.

func Join

func Join[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) V) map[K]V

Join merges two maps into one. If a key exists in both maps, the provided duplication function is called to resolve the conflict.

func JoinOrError

func JoinOrError[K comparable, V any](left, right map[K]V, dup func(K, *V, *V) (V, error)) (map[K]V, error)

JoinOrError merges two maps into one. If a key exists in both maps, the provided duplication function is called to resolve the conflict.

func MapKeys

func MapKeys[KIn, KOut comparable, V any](input map[KIn]V, f func(KIn) KOut) map[KOut]V

MapKeys applies the given function to each key of the input map and returns a new map with the transformed keys and original values.

func MapValues

func MapValues[K comparable, VIn, VOut any](input map[K]VIn, f func(K, VIn) VOut) map[K]VOut

MapValues applies the given function to each value of the input map and returns a new map with the original keys and transformed values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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