prototype

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

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 21 Imported by: 0

README

prototype

Documentation

Index

Constants

View Source
const (
	NonPointer               Code = 1
	Nil                           = 2
	Overflow                      = 3
	NegativeNumber                = 4
	FailedParse                   = 5
	PointerCycle                  = 6
	UnsupportedType               = 7
	FailedUnmarshalNew            = 9
	FailedStringify               = 10
	FailedSetEmbeddedPointer      = 11
)

Variables

This section is empty.

Functions

func Clone

func Clone(tgt any, src any, opts ...Option) error

Clone 将值从 src 克隆到 tgt

Types

type Cloner

type Cloner func(labels []string, tgtVal reflect.Value, srcVal reflect.Value) (bool, error)

Cloner is a clone hook.

type ClonerFrom

type ClonerFrom interface {
	// CloneFrom 如果返回一个错误,则终止clone, 如果bool返回true,则代表当前克隆结束,如果返回false,则代表没有克隆,需要继续克隆。
	CloneFrom(src any) (bool, error)
}

ClonerFrom 自定义克隆方法,从源克隆到自己

type ClonerTo

type ClonerTo interface {
	// CloneTo 如果返回一个错误,则终止clone, 如果bool返回true,则代表当前克隆结束,如果返回false,则代表没有克隆结束,需要继续克隆。
	CloneTo(tgt any) (bool, error)
}

ClonerTo 自定义克隆方法,将自己克隆到目标

type Code

type Code int

type Error

type Error struct {
	Code       Code
	Labels     []string
	TargetType reflect.Type
	SourceType reflect.Type
	Value      string
	// contains filtered or unexported fields
}

func (Error) Error

func (e Error) Error() string

func (Error) Unwrap

func (e Error) Unwrap() error

type Option

type Option func(o *options)

func Cloners

func Cloners(f ...Cloner) Option

func Context

func Context(ctx context.Context) Option

func DisableDeepClone

func DisableDeepClone() Option

func EqualFold

func EqualFold(f func(t, s string) bool) Option

func GetterPrefix

func GetterPrefix(p string) Option

func IntToTime

func IntToTime(f func(i int64) time.Time) Option

func InterruptOnError

func InterruptOnError() Option

func SetterPrefix

func SetterPrefix(p string) Option

func StringToTime

func StringToTime(f func(s string) (time.Time, error)) Option

func TagKey

func TagKey(key string) Option

func TimeToInt

func TimeToInt(f func(t time.Time) int64) Option

func TimeToString

func TimeToString(f func(t time.Time) string) Option

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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