Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeepCopy ¶
DeepCopy creates an optimized deep copy of any value.
Optimizations:
- Returns nil for nil input (no allocation)
- Returns empty literals for empty collections (no heap allocation)
- Fast path for primitive types (no recursion needed)
- Pre-sizes destination maps and slices to avoid growth reallocations
This function is safe for concurrent use and handles nested structures including maps, slices, and primitives.
Note: For type-safe copying of map[string]any, use DeepCopyMap instead.
func DeepCopyMap ¶
DeepCopyMap creates a type-safe deep copy of a map[string]any. This is a convenience wrapper around DeepCopy that eliminates the need for type assertions.
Example:
m := map[string]any{"key": "value"}
copied := util.DeepCopyMap(m) // Returns map[string]any directly
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.