Documentation
¶
Overview ¶
Package deepcopytest checks that a deep copy shares no mutable memory with its source. It is test support: Fill populates every exported field of a value so a Clone that forgets one is exercised, and Aliases walks a source and its copy in lockstep -- unexported fields included -- reporting every pointer, map and slice backing array the two still share.
It is reflection-based on purpose and lives outside the production path: the Clone methods it checks are hand-written because a reflective copier is slow on the hot path and cannot preserve a graph's indexes, and a check that read the same field list as the code under test would agree with it by construction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aliases ¶
Aliases reports every place where b, a deep copy of a, still shares mutable memory with it: the same non-nil pointer, the same map, or a slice whose backing array starts at the same address. Unexported fields are walked too, since a copy that shares a private index is as broken as one that shares a public field. Each entry names the path from the root.
func Fill ¶
func Fill(ptr any)
Fill populates every exported field reachable from ptr with a non-zero value: two elements per slice and map, a fresh allocation per pointer, a distinct string per position, and a nested JSON-shaped map for every empty-interface field. Unexported fields and non-empty interfaces are left for the caller to set through the type's own constructor.
Types ¶
This section is empty.