converter

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(sPtr, dPtr unsafe.Pointer, size uintptr)

func NewValuePtr

func NewValuePtr(k reflect.Kind) unsafe.Pointer

Types

type Converter

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

func NewConverter

func NewConverter(src, dst interface{}) (*Converter, error)

func NewConverterOption

func NewConverterOption(src, dst interface{}, option *StructOption) (*Converter, error)

func (*Converter) Convert

func (d *Converter) Convert(src, dst interface{}) error

type CvtOp

type CvtOp func(unsafe.Pointer, unsafe.Pointer)

func GetCvtOp

func GetCvtOp(st, dt reflect.Type) CvtOp

type StructOption

type StructOption struct {
	BannedFields []string
	AliasFields  map[string]string
}

StructOption describe options in converting struct. BannedFields lists fields that are not allowed to be converted in dst struct. AliasFields lists fields that are supposed to use alias field-name in dst struct when converting. Both BannedFields and AliasFields support nested fields. For example, `A.B` in BannedFields or key of AliasFields means `A` field in dst struct is a struct, and the option is applied to `B` field in `A`.

Jump to

Keyboard shortcuts

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