gotools/gopls/internal/clonetest/clonetest.go

// 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.
func NonZero[T any]() T {}

// nonZeroValue returns a non-zero, addressable value of the given type.
func nonZeroValue(t reflect.Type, seen []reflect.Type) reflect.Value {}

// ZeroOut recursively sets values contained in t to zero.
// Values of king Chan, Func, Interface, UnsafePointer are all unsupported.
//
// No attempt is made to handle cyclic values.
func ZeroOut[T any](t *T) {}

func zeroOutValue(v reflect.Value) {}