modelmapper

package
v0.0.0-...-c78e9a6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: LGPL-2.1 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConversion

func AddConversion[TSrcField any, TDestField any](
	converter Converter,
)

AddConversion registers a custom converter used by MapToStruct, StructToMap and StructToStruct when no automatic rule applies. When both TSrcField and TDestField are non-pointer base types, all three pointer variants (*Src->Dest, Src->*Dest, *Src->*Dest) are automatically registered as well.

func MapToStruct

func MapToStruct(src map[string]any, dest any) error

MapToStruct copies values from src map into dest struct fields matched by "json" tags. dest must be a non-nil pointer to a struct.

func StructToMap

func StructToMap(src any) (map[string]any, error)

StructToMap converts a struct into a map[string]any using "json" tags as keys. src must be a non-nil pointer to a struct.

func StructToStruct

func StructToStruct(src any, dest any) error

StructToStruct copies fields from src to dest matched by "json" tag keys. Both src and dest must be non-nil pointers to structs.

Types

type Converter

type Converter func(in reflect.Value) (reflect.Value, error)

Jump to

Keyboard shortcuts

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