mapper

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomTypes = map[reflect.Type]Setter{
	reflect.TypeOf(time.Time{}): setterTime,
}

Type registry for custom setters. Only modify in your modules init function.

Functions

func Map

func Map(tag string, source Source, target interface{}) error

Runs a mapping operation on the given target. The target must be a pointer to a struct.

Types

type MapSource

type MapSource map[string]string

Default implementation for a source that uses a simple string map for lookup.

func (MapSource) Get

func (m MapSource) Get(key string) (string, bool)

type Setter

type Setter func(value string, target reflect.Value) error

Take the given string value, converts it and assigns it to the target value. It is expected, that the target value.

type Source

type Source interface {
	Get(key string) (string, bool)
}

A source returns a value for a given key. A source might be backed by a map or something else.

Jump to

Keyboard shortcuts

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