Versions in this module Expand all Collapse all v2 v2.15.1 Mar 4, 2022 Changes in this version + const CREATE + const DELETE + const UPDATE + var ErrInvalidChangeType = NewError("change type must be one of 'create' or 'delete'") + var ErrTypeMismatch = NewError("types do not match") + func AllowTypeMismatch(enabled bool) func(d *Differ) error + func AreType(a, b reflect.Value, types ...reflect.Type) bool + func Changed(a, b interface{}) bool + func ConvertCompatibleTypes() func(d *Differ) error + func CustomValueDiffers(vd ...ValueDiffer) func(d *Differ) error + func DisableStructValues() func(d *Differ) error + func DiscardComplexOrigin() func(d *Differ) error + func Filter(f FilterFunc) func(d *Differ) error + func FlattenEmbeddedStructs() func(d *Differ) error + func SliceOrdering(enabled bool) func(d *Differ) error + func StructMapKeySupport() func(d *Differ) error + func TagName(tag string) func(d *Differ) error + type Change struct + From interface{} + Parent interface{} + Path []string + To interface{} + Type string + type ChangeValue struct + func NewChangeValue(d *Differ, c Change, target interface{}) (ret *ChangeValue) + func (c *ChangeValue) AddError(err error) *ChangeValue + func (c *ChangeValue) ClearFlag(flag PatchFlags) + func (c *ChangeValue) HasFlag(flag PatchFlags) bool + func (c *ChangeValue) IsValid() bool + func (c *ChangeValue) ParentSet(value reflect.Value, convertCompatibleTypes bool) + func (c *ChangeValue) Set(value reflect.Value, convertCompatibleTypes bool) + func (c *ChangeValue) SetFlag(flag PatchFlags) + func (c ChangeValue) Index(i int) reflect.Value + func (c ChangeValue) Len() int + func (c ChangeValue) NewArrayElement() reflect.Value + func (c ChangeValue) NewElement() reflect.Value + func (c ChangeValue) ParentIndex(i int) (ret reflect.Value) + func (c ChangeValue) ParentKind() reflect.Kind + func (c ChangeValue) ParentLen() (ret int) + type Changelog []Change + func Diff(a, b interface{}, opts ...func(d *Differ) error) (Changelog, error) + func StructValues(t string, path []string, s interface{}) (Changelog, error) + func (cl *Changelog) Add(t string, path []string, ftco ...interface{}) + func (cl *Changelog) Filter(path []string) Changelog + func (cl *Changelog) FilterOut(path []string) Changelog + type Comparative struct + A *reflect.Value + B *reflect.Value + type ComparativeList struct + func NewComparativeList() *ComparativeList + type DiffError struct + func NewError(message string, causes ...error) *DiffError + func NewErrorf(format string, messages ...interface{}) *DiffError + func (s *DiffError) Unwrap() error + func (s *DiffError) WithCause(err error) *DiffError + func (s DiffError) Error() string + type Differ struct + AllowTypeMismatch bool + ConvertCompatibleTypes bool + DisableStructValues bool + DiscardParent bool + Filter FilterFunc + FlattenEmbeddedStructs bool + SliceOrdering bool + StructMapKeys bool + TagName string + func NewDiffer(opts ...func(d *Differ) error) (*Differ, error) + func (d *Differ) Diff(a, b interface{}) (Changelog, error) + func (d *Differ) Merge(original interface{}, changed interface{}, target interface{}) (PatchLog, error) + func (d *Differ) Patch(cl Changelog, target interface{}) (ret PatchLog) + type FilterFunc func(path []string, parent reflect.Type, field reflect.StructField) bool + type PatchFlags uint32 + const FlagApplied + const FlagCreated + const FlagDeleted + const FlagFailed + const FlagIgnored + const FlagInvalidTarget + const FlagParentSetApplied + const FlagParentSetFailed + const FlagUpdated + const OptionCreate + const OptionImmutable + const OptionNoCreate + const OptionOmitUnequal + type PatchLog []PatchLogEntry + func Merge(original interface{}, changed interface{}, target interface{}) (PatchLog, error) + func Patch(cl Changelog, target interface{}) (ret PatchLog) + func (p PatchLog) Applied() bool + func (p PatchLog) ErrorCount() (ret uint) + func (p PatchLog) HasErrors() (ret bool) + type PatchLogEntry struct + Errors error + Flags PatchFlags + From interface{} + Path []string + To interface{} + func NewPatchLogEntry(cv *ChangeValue) PatchLogEntry + func (p PatchLogEntry) HasFlag(flag PatchFlags) bool + type ValueDiffer interface + Diff func(cl *Changelog, path []string, a, b reflect.Value) error + InsertParentDiffer func(dfunc func(path []string, a, b reflect.Value, p interface{}) error) + Match func(a, b reflect.Value) bool