maps

package
v1.83.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopyJSON

func DeepCopyJSON(x map[string]any) map[string]any

DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains types produced by json.Unmarshal() and also int64. bool, int64, float64, string, []any, map[string]any, json.Number and nil

func LeafPaths

func LeafPaths(m map[string]any, prefix string) []string

func MapSliceToStructSlice

func MapSliceToStructSlice[T any](in []map[string]any) ([]T, error)

func NestedFieldCopy

func NestedFieldCopy(obj map[string]any, fields ...string) (any, bool, error)

NestedFieldCopy returns a deep copy of the value of a nested field. Returns false if the value is missing. No error is returned for a nil field.

Note: fields passed to this function are treated as keys within the passed object; no array/slice syntax is supported.

func NestedMap

func NestedMap(obj map[string]any, fields ...string) (map[string]any, bool, error)

NestedMap returns a deep copy of map[string]any value of a nested field. Returns false if value is not found and an error if not a map[string]any.

func NestedMapNoCopy

func NestedMapNoCopy(obj map[string]any, fields ...string) (map[string]any, bool, error)

NestedMapNoCopy returns a map[string]any value of a nested field. Returns false if value is not found and an error if not a map[string]any.

func NestedSlice

func NestedSlice(obj map[string]any, fields ...string) ([]any, bool, error)

NestedSlice returns a deep copy of []any value of a nested field. Returns false if value is not found and an error if not a []any.

func NestedSliceNoCopy

func NestedSliceNoCopy(obj map[string]any, fields ...string) ([]any, bool, error)

func NestedString

func NestedString(obj map[string]any, fields ...string) (string, error)

func NestedValue

func NestedValue(obj map[string]any, fields []string) (any, bool)

func ParsePath

func ParsePath(path string) []string

ParsePath converts a "spec.containers[0].env[0].value" path to a string slice

func Reorder

func Reorder(input map[string]any, paths []string) map[string]any

func SetNestedField

func SetNestedField(obj map[string]any, value any, fields ...string) error

SetNestedField sets the value of a nested field to a deep copy of the value provided. Returns an error if value cannot be set because one of the nesting levels is not a map[string]any.

func SetNestedValue

func SetNestedValue(obj map[string]any, fields []string, newValue any) error

func StructSliceToMapSlice

func StructSliceToMapSlice[T any](results []T) ([]map[string]any, error)

func ToMapSlice

func ToMapSlice(in []any) ([]map[string]any, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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