fields

package
v3.8.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MIT Imports: 0 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(fields map[string]interface{}) map[string]interface{}

Expand substitutes the values-Providers in the map by the key-value pairs returned by the value's GetLoganFields() implementation.

Expand doesn't modify provided map anyhow - just returns a new (expanded) one.

func Merge

func Merge(m1 map[string]interface{}, m2 map[string]interface{}) map[string]interface{}

Merge merges two instances of `map[string]interface{}`. You can pass here as arguments any types, which are in fact `map[string]interface{}`.

If both maps has some key - the value from the `f2` will be used.

Merge does not modify any of the map - it produces a new map.

func Obtain

func Obtain(entityName string, value interface{}) map[string]interface{}

Obtain tries to extract fields from `value`, if `value` implements Provider.

type Provider interface {
	GetLoganFields() map[string]interface{}
}

If `value` does not implement Provider - a map with 1 key and plain value will be returned.

Types

type Provider

type Provider interface {
	GetLoganFields() map[string]interface{}
}

Provider if passed as a field value (see `logan.Entity.WithField()` and `errors.F.Add()`), will be transformed into map with multiple key-values: each key provided in the return map of implementation of `GetLoganFields()` will be prefixed with the key of the whole entity, using `_` delimiter. See example in tests.

Jump to

Keyboard shortcuts

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