mapify

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 2 Imported by: 1

README

Mapify

Build Go Reference Go Report Card codecov

Highly configurable struct to map converter. Also converts maps into other maps.

Features (work in progress)

  • configuration outside the struct
    • could be in a different package - separation of concerns
    • no need to modify original structs (by adding tags, implementing methods etc.)
    • behaviour as a code - you provide code which will be run during conversion
  • ability to rename keys during conversion
  • ability to omit keys based on field name, value or tag etc.
  • ability to map elements during conversion

Documentation

Overview

Package mapify converts structs (and other maps) into maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	reflect.Value
	// contains filtered or unexported fields
}

Element represents either a map entry, field of a struct or unnamed element of a slice.

func (Element) Name

func (e Element) Name() string

type Filter

type Filter func(path string, e Element) bool

Filter returns true when element should be included.

type Instance

type Instance struct {
	Filter   Filter
	Rename   Rename
	MapValue MapValue
}

Instance represents instance of mapper

func (Instance) MapAny

func (i Instance) MapAny(v interface{}) interface{}

type MapValue

type MapValue func(path string, e Element) interface{}

MapValue map (transform) element value.

type Rename

type Rename func(path string, e Element) string

Rename renames element name.

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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