maputil

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopyMap added in v0.3.1

func DeepCopyMap(in map[string]any) map[string]any

func DeepCopyValue

func DeepCopyValue(value any) any

DeepCopyValue creates a deep copy of an any value.

func DeleteValueAtPath

func DeleteValueAtPath(data any, keys []string) error

DeleteValueAtPath deletes the value at the specified path in the data map. If path is not found, this is a noop.

func GetValueAtPath

func GetValueAtPath(data any, keys []string) (any, error)

GetValueAtPath retrieves the value at the specified path in the data map.

func NavigateToParentMap(
	data any,
	keys []string,
	createMissing bool,
) (parentMap map[string]any, lastKey string, err error)

NavigateToParentMap navigates to the parent map of the last key in the given path. It returns the parent map, the last key, and any error encountered. If createMissing is true, it creates any missing maps along the path.

func SetValueAtPath

func SetValueAtPath(data any, keys []string, value any) error

SetValueAtPath sets the value at the specified path in the data map.

Types

type KeyNotFoundError

type KeyNotFoundError struct {
	Key  string
	Path string
}

KeyNotFoundError is a custom error type for missing keys.

func (*KeyNotFoundError) Error

func (e *KeyNotFoundError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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