mapconv

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const DefaultMapConvTag = "mapconv"

DefaultMapConvTag デフォルトのmapconvタグ名

Variables

This section is empty.

Functions

func ConvertFrom

func ConvertFrom(source interface{}, dest interface{}) error

ConvertFrom converts struct which input by mapconv from plain models

func ConvertTo

func ConvertTo(source interface{}, dest interface{}) error

ConvertTo converts struct which input by mapconv to plain models

Types

type Decoder added in v2.8.0

type Decoder struct {
	Config *DecoderConfig
}

Decoder mapconvでの変換

func (*Decoder) ConvertFrom added in v2.8.0

func (d *Decoder) ConvertFrom(source interface{}, dest interface{}) error

func (*Decoder) ConvertTo added in v2.8.0

func (d *Decoder) ConvertTo(source interface{}, dest interface{}) error

func (*Decoder) ParseMapConvTag added in v2.8.0

func (d *Decoder) ParseMapConvTag(tagBody string) TagInfo

ParseMapConvTag mapconvタグを文字列で受け取りパースしてTagInfoを返す

type DecoderConfig added in v2.8.0

type DecoderConfig struct {
	TagName     string
	FilterFuncs map[string]FilterFunc
}

DecoderConfig mapconvでの変換の設定

type FilterFunc added in v2.8.9

type FilterFunc func(v interface{}) (interface{}, error)

FilterFunc mapconvでの変換時に適用するフィルタ

type Map

type Map map[string]interface{}

Map is wrapper of map[string]interface{}

func (*Map) Get

func (m *Map) Get(key string) (interface{}, error)

Get returns map value with dot-separated key

func (*Map) Map

func (m *Map) Map() map[string]interface{}

Map returns output map

func (*Map) Set

func (m *Map) Set(key string, value interface{})

Set sets map value with dot-separated key

type TagInfo

type TagInfo struct {
	Ignore       bool
	SourceFields []string
	Filters      []string
	DefaultValue interface{}
	OmitEmpty    bool
	Recursive    bool
	Squash       bool
	IsSlice      bool
}

TagInfo mapconvタグの情報

Jump to

Keyboard shortcuts

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