utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareAndCopyMaps

func CompareAndCopyMaps(src, tgt map[string]any) map[string]any

CompareAndCopyMaps compares two map[string]any for deep equality. If they are different, it returns a deep copy of the first map. If they are the same, it returns nil.

func DeepCopyMap

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

DeepCopyMap creates a deep copy of a map[string]any, handling nested maps, slices, and other complex types recursively.

func GenerateRandomSerial

func GenerateRandomSerial(length int) string

GenerateRandomSerial generates a random serial number of specified length

func JSONStringToMap

func JSONStringToMap(n string, s string) map[string]any

JSONStringToMap tries to parse a JSON string `s` into a map. If parsing fails, it returns a map with the original string as a value uder key `n`

func MapToJSONString

func MapToJSONString(m map[string]any) string

MapToJSONString converts a map to its JSON string representation. Returns empty string if marshaling fails.

func StringToMap

func StringToMap(s string) map[string]any

StringToMap tries to parse a string `s` into a map. If parsing fails, it returns nil.

func StructToMap

func StructToMap(obj any) map[string]any

StructToMap converts a struct to a map[string]any using reflection. It handles nested structs recursively and respects json tags and returns empty map for non-struct inputs

Types

This section is empty.

Jump to

Keyboard shortcuts

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