clonetest

package
v0.0.0-...-b73abcb Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 2 Imported by: 0

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.

func ZeroOut

func ZeroOut[T any](t *T)

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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