clone

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 4 Imported by: 8

README

Generic go-clone API

Go Go Doc

This package is a set of generic API for go-clone. Almost all methods are simple proxies with a few exceptions. It requires go1.18 or later to build this package.

Please read document in the main project for more information.

Documentation

Overview

Package clone provides functions to deep clone any Go data. It also provides a wrapper to protect a pointer from any unexpected mutation.

This package is only a proxy to original go-clone package with generic support. To minimize the maintenace cost, there is no doc in this package. Please read the document in https://pkg.go.dev/github.com/huandu/go-clone instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[T any](t T) T

func IsScalar added in v1.6.0

func IsScalar(k reflect.Kind) bool

func MarkAsOpaquePointer

func MarkAsOpaquePointer(t reflect.Type)

func MarkAsScalar

func MarkAsScalar(t reflect.Type)

func RegisterAtomicPointer

func RegisterAtomicPointer[T any]()

RegisterAtomicPointer registers a custom clone function for atomic.Pointer[T].

func SetCustomFunc

func SetCustomFunc(t reflect.Type, fn Func)

func Slowly

func Slowly[T any](t T) T

func Undo

func Undo[T any](t T)

func Unwrap

func Unwrap[T any](t T) T

func Wrap

func Wrap[T any](t T) T

Types

type Allocator added in v1.5.0

type Allocator = clone.Allocator

func FromHeap added in v1.5.0

func FromHeap() *Allocator

func NewAllocator added in v1.5.0

func NewAllocator(pool unsafe.Pointer, methods *AllocatorMethods) (allocator *Allocator)

type AllocatorMethods added in v1.5.0

type AllocatorMethods = clone.AllocatorMethods

type Cloner added in v1.6.0

type Cloner = clone.Cloner

func MakeCloner added in v1.6.0

func MakeCloner(allocator *Allocator) Cloner

type Func

type Func = clone.Func

Jump to

Keyboard shortcuts

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