typemapper

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MPL-2.0 Imports: 0 Imported by: 0

README

typemapper

Convention based code generator to simplify mapping between similar structs in Go.

Copying data between similar, but slightly different, structs is error-prone, especially as the size of struct increases. typemapper simplifies the process using common conventions to automatically generate mapping functions and helps ensure no fields are left out the copying process but generating unit test files that fail when one is missed.

How it Works

See the Tutorial.

TODO

  • Sync tutorial example files with markdown doc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMap

func CreateMap(src interface{}, dst interface{})

CreateMap initiates a mapping from the src type to the dst type.

func IgnoreFields

func IgnoreFields(dstFields ...interface{})

IgnoreFields tells the map to ignore certain destination fields.

func IgnoreUnexported

func IgnoreUnexported()

IgnoreUnexported tells the map to ignore unexported destination fields.

func MapField

func MapField(srcField interface{}, dstField interface{})

MapField tells the map to explicitly match fields that would otherwise not match.

func MapWith

func MapWith(mappingFuncs ...interface{})

MapWith provides additional mapping functions to use for type conversions.

func RecognizePrefixes

func RecognizePrefixes(prefix ...string)

RecognizePrefixes tells the map to match fields where the names match ignoring certain prefixes.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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