mapper

package
v0.0.0-...-4b4a10f Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SrcKeyIndex = iota
	DestKeyIndex
)

Variables

View Source
var (
	// ErrNilFunction is the error returned by CreateCustomMap or CreateMapWith
	// if a nil function is passed to the method.
	ErrNilFunction = errors.New("mapper: nil function")
	// ErrMapNotExist is the error returned by the Map method
	// if a map for given types does not exist.
	ErrMapNotExist = errors.New("mapper: map does not exist")
	// ErrMapAlreadyExists is the error returned by one of the CreateMap method
	// if a given map already exists. Mapper does not allow to override MapFunc.
	ErrMapAlreadyExists = errors.New("mapper: map already exists")
	// ErrUnsupportedMap is the error returned by CreateMap or CreateMapWith
	// if a source - destination mapping is not supported. The mapping is supported only for
	// structs to structs with at least one exported field by a src side which corresponds to a dst field.
	ErrUnsupportedMap = errors.New("mapper: unsupported map")
)

Functions

func Configure

func Configure(config *MapperConfig)

func CreateCustomMap

func CreateCustomMap[TSrc any, TDst any](fn MapFunc[TSrc, TDst]) error

func CreateMap

func CreateMap[TSrc any, TDst any]() error

func Map

func Map[TDes any, TSrc any](src TSrc) (TDes, error)

Types

type MapFunc

type MapFunc[TSrc any, TDst any] func(TSrc) TDst

type MapperConfig

type MapperConfig struct {
	MapUnexportedFields bool
}

Jump to

Keyboard shortcuts

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