maputil

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package maputil provides generic helpers for map transformations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter added in v0.0.12

func Filter[K comparable, V any](m map[K]V, fn func(K, V) bool) map[K]V

Filter returns a new map containing entries that satisfy fn.

func GetOr added in v0.0.12

func GetOr[K comparable, V any](m map[K]V, key K, fallback V) V

GetOr returns m[key], or fallback when key does not exist.

func Keys

func Keys[K comparable, V any](m map[K]V) []K

Keys returns all keys from m.

func MapValues

func MapValues[K comparable, V any, U any](m map[K]V, fn func(V) U) map[K]U

MapValues transforms map values while preserving keys.

func Merge

func Merge[K comparable, V any](maps ...map[K]V) map[K]V

Merge merges maps into a new map. Later maps override earlier maps.

func Omit

func Omit[K comparable, V any](m map[K]V, keys ...K) map[K]V

Omit returns a new map without selected keys.

func Pick

func Pick[K comparable, V any](m map[K]V, keys ...K) map[K]V

Pick returns a new map containing only selected keys.

func Values

func Values[K comparable, V any](m map[K]V) []V

Values returns all values from m.

Types

This section is empty.

Jump to

Keyboard shortcuts

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