Documentation
¶
Index ¶
Constants ¶
const ( // WithoutEqualityChecks option makes the merge skip all pre-merge equality checks. WithoutEqualityChecks equalityCheckOption = iota // WithInitialEqualityCheck option makes the merge check for equality of the input values before merging them to potentially skip costly merges. WithInitialEqualityCheck // WithSubtreeEqualityChecks option makes the merge check for equality of every value pair before merging them to potentially skip costly merges. WithSubtreeEqualityChecks )
const ( // UseFirst is a merge strategy that always returns the first value without modifying it. UseFirst useFirstMergeStrategy = true // UseSecond is a merge strategy that always returns the second value without modifying it. UseSecond useFirstMergeStrategy = false )
const Identity identityTransformation = false
Identity is the identity transformation
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MergeContext ¶
type MergeContext struct {
// contains filtered or unexported fields
}
MergeContext stores merge state and configuration
func NewMergeContext ¶
func NewMergeContext(options ...MergeOption) MergeContext
NewMergeContext returns a new MergeContext with the specified MergeOptions applied to it.
type MergeOption ¶
type MergeOption interface {
// contains filtered or unexported methods
}
MergeOption represents a merge configuration option.
type MergeOptions ¶
type MergeOptions []MergeOption
MergeOptions represent a list of merge configuration options.
type MergeStrategy ¶
type MergeStrategy interface { // Merge merges two values using the provided MergeContext. Merge(ctx MergeContext, fst, snd Value) (Value, error) }
MergeStrategy represents a merge strategy.
type MergeStrategyFunc ¶
type MergeStrategyFunc func(MergeContext, Value, Value) (Value, error)
MergeStrategyFunc adapts a function to a MergeStrategy.
func (MergeStrategyFunc) Merge ¶
func (fn MergeStrategyFunc) Merge(ctx MergeContext, fst, snd Value) (Value, error)
Merge merges two values by delegating to the merge strategy function.
type MergeStrategyOption ¶
type MergeStrategyOption struct {
// contains filtered or unexported fields
}
MergeStrategyOption represents a merge strategy configuration option.
func WithStrategy ¶
func WithStrategy(fstType, sndType reflect.Type, strategy MergeStrategy) MergeStrategyOption
WithStrategy returns a MergeStrategyOption with the provided parameters.
type Transformation ¶
type Transformation interface { // Transform performs the transformation Transform(Value) (Value, error) }
Transformation can transform a value to another
func Compose ¶
func Compose(transformations ...Transformation) Transformation
Compose returns the composition of the specified transformations performed in order
type TransformationFunc ¶
TransformationFunc wraps a function that implements the transformation
type Value ¶
type Value = interface{}
Value can represent any value
func Merge ¶
func Merge(fst, snd Value, options ...MergeOption) (Value, error)
Merge returns the merge of its first and second arguments.
func MergeWithContext ¶
func MergeWithContext(ctx MergeContext, fst, snd Value) (Value, error)
MergeWithContext returns the merge of fst and snd using the specified MergeContext.
func MustMerge ¶
func MustMerge(fst, snd Value, options ...MergeOption) Value
MustMerge returns the merge of its first and second arguments. It panics if there were any errors during merging.