maps

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add[K comparable, V any](mp map[K]V, k K, v V)

Add an element to a map if it doesn't exist.

func Exists

func Exists[K comparable, V any](mp map[K]V, key K) bool

Exists checks if the given key exists in the provided map.

func Forget

func Forget[K comparable, V any](mp map[K]V, keys ...K)

Forget removes a given key or keys from the provided map.

func FromStruct

func FromStruct(data any) map[string]any

func Get

func Get[K comparable, V any](mp map[K]V, key K, defaults ...V) V

Get an element from a map

func Has

func Has[K comparable, V any](mp map[K]V, keys ...K) bool

Has checks if the given key or keys exist in the provided map.

func HasAny

func HasAny[K comparable, V any](mp map[K]V, keys ...K) bool

HasAny checks if the given key or keys exist in the provided map.

func Only

func Only[K comparable, V any](mp map[K]V, keys ...K) map[K]V

Only returns the items in the map with the specified keys.

func Pull

func Pull[K comparable, V any](mp map[K]V, key K, def ...V) V

Pull returns a new map with the specified keys removed.

func Set

func Set[K comparable, V any](mp map[K]V, k K, v V)

Set an element to a map.

func Where

func Where[K comparable, V any](mp map[K]V, callback func(K, V) bool) map[K]V

Where filters the items in a map using the given callback.

Types

This section is empty.

Jump to

Keyboard shortcuts

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