cloner

package
v0.73.6-beta2025021401 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cloner provides functions to deep clone any Go data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[T any](src T, opts ...Option) T

Clone returns a deep cloned instance of the given `src` variable.

Types

type Cloner

type Cloner[T any] struct {
	*Config
}

func (*Cloner[T]) Clone

func (cloner *Cloner[T]) Clone(src T) T

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Option

type Option func(*Config)

Option represents an option to customize deep copied results.

func WithShadowCopyInversePkgPrefixes

func WithShadowCopyInversePkgPrefixes(prefixes ...string) Option

WithShadowCopyInversePkgPrefixes returns an `Option` that forces shadow copies of types whose pkg paths do not match the given `prefixes`.

func WithShadowCopyTypes

func WithShadowCopyTypes(values ...any) Option

WithShadowCopyTypes returns an `Option` that forces shadow copies of the types that are in the given `values`.

func WithSkippingTypes

func WithSkippingTypes(values ...any) Option

WithSkippingTypes returns an `Option` that forces skipping copying types that are in the given `values`.

Jump to

Keyboard shortcuts

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