copier

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RFC3339Mili = "2006-01-02T15:04:05.999Z07:00"

Variables

This section is empty.

Functions

func RFC3339Convertor

func RFC3339Convertor(m Mapper)

Types

type Converter

type Converter func(from reflect.Value, toType reflect.Type) (reflect.Value, error)

type CopyCommand

type CopyCommand interface {
	CopyTo(toValue interface{}) error
}

type DiffFieldPair

type DiffFieldPair struct {
	Origin  string
	Targets []string
}

type FieldKey

type FieldKey string

type Mapper

type Mapper interface {
	From(fromValue interface{}) CopyCommand

	RegisterConverter(matcher TypeMatcher, converter Converter) Mapper

	RegisterConverterFunc(matcher TypeMatcherFunc, converter Converter) Mapper

	RegisterResetDiffField(diffFields []DiffFieldPair) Mapper

	RegisterIgnoreTargetFields(targetFieldKeys []FieldKey) Mapper

	RegisterTransformer(transformer Transformer) Mapper

	Install(Module) Mapper
}

func Instance

func Instance(option *Option) Mapper

func InstanceWithContext

func InstanceWithContext(ctx context.Context, option *Option) Mapper

type Module

type Module func(Mapper)

type Option

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

func NewOption

func NewOption() *Option

func NewOptionWithContext

func NewOptionWithContext(ctx context.Context) *Option

func (*Option) SetContext

func (o *Option) SetContext(ctx context.Context) *Option

func (*Option) SetCopyUnexported

func (o *Option) SetCopyUnexported(copyUnexported bool) *Option

SetCopyUnexported 未导出字段是否拷贝

func (*Option) SetIgnoreEmpty

func (o *Option) SetIgnoreEmpty(ignoreEmpty bool) *Option

func (*Option) SetOverwrite

func (o *Option) SetOverwrite(overwrite bool) *Option

func (*Option) SetOverwriteOriginalCopyField

func (o *Option) SetOverwriteOriginalCopyField(overwriteOriginalCopyField bool) *Option

func (*Option) SetSkipUnsuited

func (o *Option) SetSkipUnsuited(skipUnsuited bool) *Option

type Target

type Target struct {
	From reflect.Type
	To   reflect.Type
}

func (Target) Matches

func (t Target) Matches(target Target) bool

type Transformer

type Transformer map[string]interface{}

type TypeMatcher

type TypeMatcher interface {
	Matches(Target) bool
}

type TypeMatcherFunc

type TypeMatcherFunc func(Target) bool

func (TypeMatcherFunc) Matches

func (f TypeMatcherFunc) Matches(target Target) bool

Jump to

Keyboard shortcuts

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