Documentation
¶
Index ¶
- Variables
- func WithCombinedIdentifierJoinString(joinSep rune) func(c *Comparer) error
- func WithEmbeddedStructsAsField() func(c *Comparer) error
- func WithSliceOrdering() func(c *Comparer) error
- func WithStructMapKeys() func(c *Comparer) error
- func WithSummarizeMissingStructs() func(c *Comparer) error
- func WithTagName(tag string) func(c *Comparer) error
- type ComparableList
- type ComparableListEntry
- type CompareFunc
- type CompareOptsFunc
- type Comparer
- type DiffType
- type Difference
- type DifferenceFilterFunc
- func WhereDiffType(dt DiffType) DifferenceFilterFunc
- func WhereOr(filterFunc ...DifferenceFilterFunc) DifferenceFilterFunc
- func WherePath(p string) DifferenceFilterFunc
- func WherePathAt(p string, idx int) DifferenceFilterFunc
- func WherePathDepth(l int) DifferenceFilterFunc
- func WherePathDepthGt(l int) DifferenceFilterFunc
- func WherePathDepthLt(l int) DifferenceFilterFunc
- type Differences
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTypeMismatch Compared types do not match ErrTypeMismatch = errors.New("types do not match") // ErrInvalidChangeType The specified change values areKind not unsupported ErrInvalidChangeType = errors.New("diff type must be one of 'ADDED' or 'REMOVED'") )
Functions ¶
func WithCombinedIdentifierJoinString ¶
WithCombinedIdentifierJoinString allows to define custom identifier join string if templating is not used
func WithEmbeddedStructsAsField ¶
WithEmbeddedStructsAsField will put the embedded struct as path name
func WithSliceOrdering ¶
WithSliceOrdering determines whether the ordering of items in a slice results in a change
func WithStructMapKeys ¶
WithStructMapKeys will encode complex map keys with gob/base64 to be used as path element
func WithSummarizeMissingStructs ¶
WithSummarizeMissingStructs will add the whole struct as change and does not try to elems every struct field as change
func WithTagName ¶
WithTagName sets the tag name to use when getting field names and options
Types ¶
type ComparableList ¶
type ComparableList struct {
// contains filtered or unexported fields
}
ComparableList stores an indexed elems of ComparableListEntry items
func NewComparableList ¶
func NewComparableList() *ComparableList
NewComparableList returns a new ComparableList
type ComparableListEntry ¶
ComparableListEntry is an object holding two items that can be compared
type CompareFunc ¶
CompareFunc represents the built-in compare functions
type CompareOptsFunc ¶
type Comparer ¶
type Comparer struct {
// contains filtered or unexported fields
}
Comparer a configurable compare instance
func NewComparer ¶
func NewComparer(opts ...CompareOptsFunc) (*Comparer, error)
NewComparer creates a new configurable diffing object
type Difference ¶
type Difference struct {
Type DiffType `json:"type"`
Path []string `json:"path"`
Left any `json:"left"`
Right any `json:"right"`
}
Difference stores information about a changed item
type DifferenceFilterFunc ¶
type DifferenceFilterFunc func(Difference) bool
DifferenceFilterFunc is a function to filter for Difference`s in Differences
func WhereDiffType ¶
func WhereDiffType(dt DiffType) DifferenceFilterFunc
WhereDiffType filters Differences - if Difference type is dt
func WhereOr ¶
func WhereOr(filterFunc ...DifferenceFilterFunc) DifferenceFilterFunc
WhereOr combines multiple DifferenceFilterFunc's as GetDifferences accepts DifferenceFilterFunc's but the result is AND'ed With WhereOr you can combine almost any logic construct to filter Differences
func WherePath ¶
func WherePath(p string) DifferenceFilterFunc
WherePath filters Differences - if p is in Difference path
func WherePathAt ¶
func WherePathAt(p string, idx int) DifferenceFilterFunc
WherePathAt filters Differences - if p is at index in Difference path
func WherePathDepth ¶
func WherePathDepth(l int) DifferenceFilterFunc
WherePathDepth filters Differences - if Difference path is of length l
func WherePathDepthGt ¶
func WherePathDepthGt(l int) DifferenceFilterFunc
WherePathDepthGt filters Differences - if Difference path is greater than l
func WherePathDepthLt ¶
func WherePathDepthLt(l int) DifferenceFilterFunc
WherePathDepthLt filters Differences - if Difference path is less than l
type Differences ¶
type Differences []Difference
Differences is a list of elements of Difference items
func Compare ¶
func Compare(left, right any, opts ...CompareOptsFunc) (Differences, error)
Compare returns a changelog of all mutated values from both
func (*Differences) GetDifferences ¶
func (d *Differences) GetDifferences(filterFunc ...DifferenceFilterFunc) iter.Seq[Difference]
GetDifferences returns Difference's as iter.Seq filtered by filter functions
func (*Differences) HasDifferences ¶
func (d *Differences) HasDifferences(filterFunc ...DifferenceFilterFunc) bool
HasDifferences returns true/false if Difference´s exists with applied filters