structmerge

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FieldPathSeparator is used to separate field names
	FieldPathSeparator = "."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Merge

type Merge struct {
	// contains filtered or unexported fields
}

Merge is a structure used for merger implementation(s)

func (*Merge) Merge

func (m *Merge) Merge(data interface{}, s *Sources) ([]MergedMeta, error)

Merge merges all sources into given data. All types of data and sources must be the same.

type MergedMeta

type MergedMeta struct {
	FieldPath string
	Source    string
	Value     string // WARNING! For security reasons, don't print or log all values (e.g. passwords can be a sensitive data)
}

MergedMeta holds metadata of merged source

type Merger

type Merger interface {
	Merge(destination interface{}, s *Sources) ([]MergedMeta, error)
}

Merger ...

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source holds source

func NewSource

func NewSource(name string, data interface{}) *Source

NewSource creates new instance of the source

func (*Source) Data

func (s *Source) Data() interface{}

Data returns source data

func (*Source) Name

func (s *Source) Name() string

Name returns source name

func (*Source) WithOrderID

func (s *Source) WithOrderID(orderID int) *Source

WithOrderID sets order id

type Sources

type Sources struct {
	// contains filtered or unexported fields
}

Sources holds sources

func NewSources

func NewSources() *Sources

NewSources creates new instance

func (*Sources) Add

func (s *Sources) Add(name string, data interface{}) *Sources

Add adds source to the sources with the given name

func (Sources) Sources

func (s Sources) Sources() []*Source

Sources returns sources list

type StructMerge

type StructMerge struct {
	MergedMeta []MergedMeta
	// contains filtered or unexported fields
}

StructMerge holds sources and merged metadata

func NewStructMerge

func NewStructMerge() *StructMerge

NewStructMerge creates new instance

func (*StructMerge) Merge

func (sm *StructMerge) Merge(data interface{}) error

Merge merges structures into given data using default implementation of merger

func (*StructMerge) MergeWithMerger

func (sm *StructMerge) MergeWithMerger(data interface{}, m Merger) error

MergeWithMerger merges structures into given data with custom merger

func (*StructMerge) WithSource

func (sm *StructMerge) WithSource(name string, data interface{}) *StructMerge

WithSource adds data with given name to the sources

func (*StructMerge) WithSources

func (sm *StructMerge) WithSources(s *Sources) *StructMerge

WithSources sets sources

Jump to

Keyboard shortcuts

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