maputil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package maputil provides utilities and helpers for scenarios not covered by the pkg/maps package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Keys added in v0.0.2

func Keys[M ~map[K]V, K comparable, V any](self M) []K

Keys gets a slice of all the keys in a map, in arbitrary order.

func MapToStruct added in v0.0.2

func MapToStruct[T any](m map[string]any) (T, error)

MapToStruct converts a map to a struct by converting through json.

func Merge added in v0.0.2

func Merge[M ~map[K]V, K comparable, V any](all ...M) M

Merge all the maps into a new map.

func SortKeys added in v0.0.2

func SortKeys[M ~map[K]V, K comparable, V any](self M, pred func(a, b K) bool) []K

SortKeys gets a slice of all the keys in a map, sorted by a predicate func.

func SortValues added in v0.0.2

func SortValues[M ~map[K]V, K comparable, V any](self M, pred func(a, b K) bool) []V

SortValues gets a slice of all the values in a map, ordered by the keys, sorted by a predicate func.

func SortedKeys

func SortedKeys[M ~map[K]V, K cmp.Ordered, V any](self M) []K

SortedKeys gets a slice of all the keys in a map, sorted.

func SortedValues added in v0.0.2

func SortedValues[M ~map[K]V, K cmp.Ordered, V any](self M) []V

SortedValues gets a slice of all the values in a map, ordered by the keys.

func StructToMap added in v0.0.2

func StructToMap[T any](t T) (map[string]any, error)

StructToMap converts a struct to a map by converting through json.

func Values added in v0.0.2

func Values[M ~map[K]V, K comparable, V any](self M) []V

Values gets a slice of all the values in a map, in arbitrary order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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