slicemap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Overview

Package slicemap provides simple slice & map utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMap

func CopyMap(m map[string]any) map[string]any

CopyMap makes a deep copy of a map.

func Get

func Get[T any](m map[string]any, field string) (res T, ok bool)

Get returns a value from a map in a specified type. If either item is not present or of a different type, ok = false.

func In

func In[T Ordered](s []T, query T) bool

In check if query is an element of the list.

func Lookup

func Lookup(data map[string]any, path []string) (any, error)

Lookup takes a map and will return a nested key.

func SetValue

func SetValue(data map[string]any, path []string, value any)

SetValue takes a map and will assign a value at the specified path.

Types

type Float added in v0.1.0

type Float interface {
	~float32 | ~float64
}

Float contains a list of float types.

type Integer added in v0.1.0

type Integer interface {
	Signed | Unsigned
}

Integer contains a list of integer types.

type Ordered added in v0.1.0

type Ordered interface {
	Integer | Float | ~string
}

Ordered contains a list of ordered types.

type Signed added in v0.1.0

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

Signed contains a list of signed types.

type Unsigned added in v0.1.0

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Unsigned contains a list of unsigned types.

Jump to

Keyboard shortcuts

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