Documentation ¶
Overview ¶
Package clonetest provides utility functions for testing Clone operations.
The NonZero helper may be used to construct a type in which fields are recursively set to a non-zero value. This value can then be cloned, and the ZeroOut helper can set values stored in the clone to zero, recursively. Doing so should not mutate the original.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NonZero ¶
func NonZero[T any]() T
NonZero returns a T set to some appropriate nonzero value:
- Values of basic type are set to an arbitrary non-zero value.
- Struct fields are set to a non-zero value.
- Array indices are set to a non-zero value.
- Pointers point to a non-zero value.
- Maps and slices are given a non-zero element.
- Chan, Func, Interface, UnsafePointer are all unsupported.
NonZero breaks cycles by returning a zero value for recursive types.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.