Documentation
¶
Overview ¶
Package clone provides helpers for copying reference types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
Any copies maps and slices that can be represented by values decoded from YAML or JSON. Other values are returned unchanged.
func Deep ¶ added in v0.117.0
func Deep[T any](dst, src *T)
Deep creates an independent copy of src into dst using reflection. It recursively copies structs, arrays, pointers, slices, maps and interface values, so that no reference-type field of dst shares storage with src. It is a no-op if either dst or src is nil.
Unexported struct fields cannot be traversed by reflection, so they are copied bitwise, exactly as a plain `*dst = *src` assignment would. Types whose unexported fields hold references (for example a struct wrapping a private slice) therefore still share that storage with src.
Cyclic references are not supported and cause unbounded recursion.
Types ¶
This section is empty.