automapper

package module
v0.0.0-...-4359ab6 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 4 Imported by: 0

README

automapper

Documentation

Overview

Package automapper contains Mapper used to map two structs or slices automatically.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAPtr                   = errors.New("value is not a ptr")
	ErrNotAFn                    = errors.New("value is not a function")
	ErrMissingConverter          = errors.New("converter is missing for types")
	ErrConverter                 = errors.New("converter error")
	ErrConverterErrorUnknownType = errors.New("converter 2nd return value cannot be converted to error")
)

Functions

This section is empty.

Types

type Mapper

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

Mapper maps struct values.

func New

func New() *Mapper

New returns new Mapper.

func (*Mapper) Map

func (m *Mapper) Map(from, to interface{}) error

Map maps two structs or two slices of structs.

func (*Mapper) Set

func (m *Mapper) Set(converter interface{}) error

Set sets converter function. Converter function must be in one of two forms:

func(in int) string
func(in string) (int, error)

Set will make the Mapper use the converter function to map in-type to out-type every time the Mapper comes across one.

Jump to

Keyboard shortcuts

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