copier

package module
v0.0.0-...-96b2f56 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 10 Imported by: 0

README

Copier

I am a copier, I copy everything from one to another

source: http://github.com/jinzhu/copier

Documentation

Index

Constants

View Source
const (

	// Some default converter types for a nicer syntax
	String  string  = ""
	Bool    bool    = false
	Int     int     = 0
	Float32 float32 = 0
	Float64 float64 = 0
)

These flags define options for tag handling

Variables

View Source
var (
	NotMatchErr       = errors.New("src type not matching")
	FmtDateTime       = "2006-01-02 15:04:05"
	Int64       int64 = 0
)
View Source
var (
	ErrInvalidCopyDestination        = errors.New("copy destination must be non-nil and addressable")
	ErrInvalidCopyFrom               = errors.New("copy from must be non-nil and addressable")
	ErrMapKeyNotMatch                = errors.New("map's key type doesn't match")
	ErrNotSupported                  = errors.New("not supported")
	ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case")
)

Functions

func Copiers

func Copiers(toValue interface{}, fromValue interface{}) error

Copiers Set default conversion rules:

func Copy

func Copy(toValue interface{}, fromValue interface{}) (err error)

Copy copy things

func CopyWithOption

func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)

CopyWithOption copy with option

Types

type Option

type Option struct {
	// setting this value to true will ignore copying zero values of all the fields, including bools, as well as a
	// struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go)
	IgnoreEmpty bool
	DeepCopy    bool
	Converters  []TypeConverter
}

Option sets copy options

type TypeConverter

type TypeConverter struct {
	SrcType interface{}
	DstType interface{}
	Fn      func(src interface{}) (dst interface{}, err error)
}

Jump to

Keyboard shortcuts

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