utils

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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