clone

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopy

func DeepCopy(v any) any

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

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

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.

Jump to

Keyboard shortcuts

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