clone

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Map

func Map[K, V Copy](src map[K]V) map[K]V

Map shallowly clones a map. The returned map is never nil.

func Slice

func Slice[T Copy](src []T) []T

// Deep recursively clones an item of any kind. This uses reflection to traverse lists, etc. // It will panic if it hits a loop. Don't use this in prod.

func Deep[V any](src V) (dst V) {
	return deep(reflect.ValueOf(src), 0).Interface().(V)
}

Slice shallowly clones a slice. The new slice is never nil.

Types

type Copy

type Copy interface {
	~string | constraints.Complex | constraints.Integer | ~bool | constraints.Float
}

Copy types are primitives and copied during assignment.

Jump to

Keyboard shortcuts

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