clonerex

package
v0.0.0-...-767a6c3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package clonerex is an example package for the cloner tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(dst, src any) bool

Clone duplicates src into dst and reports whether it succeeded. To succeed, <src, dst> must be of types <*T, *T> or <*T, **T>, where T is one of SliceContainer,InterfaceContainer,MapWithPointers,DeeplyNestedMap,NamedMapContainer,MapSlicePointerContainer.

Types

type Cloneable

type Cloneable interface {
	Clone() Cloneable
}

Cloneable is an interface with a Clone method.

type CloneableImpl

type CloneableImpl struct {
	Value int
}

CloneableImpl is a concrete type that implements Cloneable.

func (*CloneableImpl) Clone

func (c *CloneableImpl) Clone() Cloneable

type DeeplyNestedMap

type DeeplyNestedMap struct {
	ThreeLevels map[string]map[string]map[string]int
	FourLevels  map[string]map[string]map[string]map[string]*SliceContainer
}

DeeplyNestedMap tests arbitrary depth of map nesting (3+ levels)

func (*DeeplyNestedMap) Clone

func (src *DeeplyNestedMap) Clone() *DeeplyNestedMap

Clone makes a deep copy of DeeplyNestedMap. The result aliases no memory with the original.

type InterfaceContainer

type InterfaceContainer struct {
	Interface Cloneable
}

InterfaceContainer has a pointer to an interface field, which tests the special handling for interface types in the cloner.

func (*InterfaceContainer) Clone

func (src *InterfaceContainer) Clone() *InterfaceContainer

Clone makes a deep copy of InterfaceContainer. The result aliases no memory with the original.

type MapSlicePointerContainer

type MapSlicePointerContainer struct {
	Routes map[string][]*SliceContainer
}

MapSlicePointerContainer has a map whose values are slices of pointers. This tests that the cloner deep-clones the pointer elements in the slice, not just the slice itself (which would leave aliased pointers).

func (*MapSlicePointerContainer) Clone

Clone makes a deep copy of MapSlicePointerContainer. The result aliases no memory with the original.

type MapWithPointers

type MapWithPointers struct {
	Nested          map[string]*int
	WithCloneMethod map[string]*SliceContainer
	CloneInterface  map[string]Cloneable
}

func (*MapWithPointers) Clone

func (src *MapWithPointers) Clone() *MapWithPointers

Clone makes a deep copy of MapWithPointers. The result aliases no memory with the original.

type NamedMap

type NamedMap map[string]any

NamedMap is a named map type with its own Clone method. This tests that the cloner uses the type's Clone method rather than trying to descend into the map's value type.

func (NamedMap) Clone

func (m NamedMap) Clone() NamedMap

type NamedMapContainer

type NamedMapContainer struct {
	Attrs NamedMap
}

NamedMapContainer has a field whose type is a named map with a Clone method.

func (*NamedMapContainer) Clone

func (src *NamedMapContainer) Clone() *NamedMapContainer

Clone makes a deep copy of NamedMapContainer. The result aliases no memory with the original.

type SliceContainer

type SliceContainer struct {
	Slice []*int
}

func (*SliceContainer) Clone

func (src *SliceContainer) Clone() *SliceContainer

Clone makes a deep copy of SliceContainer. The result aliases no memory with the original.

Jump to

Keyboard shortcuts

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