kv

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package kv provides fluent operations on Go maps (key-value collections).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keys

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

Keys extracts the keys of m as a Mapper for further transformation. Shortcut for From(m).Keys().

func Map

func Map[K comparable, V, T any](m map[K]V, fn func(K, V) T) base.Mapper[T]

Map transforms each key-value pair in m using fn and returns the results as a Mapper. All type parameters are inferred from the arguments. Use MapTo[T](m).Map(fn) when explicit type specification is needed. Order is not guaranteed (map iteration order).

func Values

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

Values extracts the values of m as a Mapper for further transformation. Shortcut for From(m).Values().

Types

type Entries

type Entries[K comparable, V any] = base.Entries[K, V]

Entries is a defined type over map[K]V. Indexing, ranging, and len all work as with a plain map. The zero value is a nil map — safe for reads (len, range) but panics on write. From does not copy; the Entries and the original map share the same backing data.

func From

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

From converts a map to Entries for fluent operations.

type MapperTo

type MapperTo[T any, K comparable, V any] = base.EntryMapper[T, K, V]

MapperTo wraps a map for cross-type transformation.

func MapTo

func MapTo[T any, K comparable, V any](m map[K]V) MapperTo[T, K, V]

MapTo wraps a map for transformation to type T. Usage: kv.MapTo[TargetType](m).Map(fn)

Jump to

Keyboard shortcuts

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