clone

package module
v0.0.0-...-e8b755e Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 4 Imported by: 0

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

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

type Allocator = clone.Allocator

func FromHeap

func FromHeap() *Allocator

func NewAllocator

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

type AllocatorMethods

type AllocatorMethods = clone.AllocatorMethods

type Cloner

type Cloner = clone.Cloner

func MakeCloner

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