Documentation
¶
Index ¶
- type Diff
- type DiffKey
- type DiffOption
- func WithBoolDiff(old, new bool) DiffOption
- func WithChildren(children ...*Diff) DiffOption
- func WithKey(key string) DiffOption
- func WithOptionalBoolDiff(old, new *bool) DiffOption
- func WithOptionalStringDiff(old, new *string) DiffOption
- func WithStringDiff(old, new string) DiffOption
- func WithStringSliceDiff(old, new []string) DiffOption
- type DiffSummary
- type Diffable
- type Op
- type StringDiffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diff ¶
type Diff struct {
Key string `json:"key"`
Diff *DiffKey `json:"diff,omitempty"`
Children []*Diff `json:"children,omitempty"`
}
func MapDiff ¶ added in v0.19.1012
MapDiff diffs two map[string]string values, returning a parent node with per-key children. Returns nil if both maps are empty/nil.
func NewDiff ¶
func NewDiff(opts ...DiffOption) *Diff
func (*Diff) FormatChanged ¶ added in v0.19.1012
FormatChanged returns only the parts of the diff tree that have changes (added, removed, or changed). Unchanged fields and sections are omitted entirely.
func (*Diff) String ¶
String returns the full diff tree with +/-/~ prefixes indicating added, removed, changed, and unchanged fields. Empty unchanged fields (both old and new are "") are suppressed.
func (*Diff) Summary ¶
func (d *Diff) Summary() DiffSummary
type DiffOption ¶
type DiffOption func(*Diff)
func WithBoolDiff ¶ added in v0.19.1012
func WithBoolDiff(old, new bool) DiffOption
WithBoolDiff creates a DiffOption that compares two bool values.
func WithChildren ¶
func WithChildren(children ...*Diff) DiffOption
func WithKey ¶
func WithKey(key string) DiffOption
func WithOptionalBoolDiff ¶ added in v0.19.1012
func WithOptionalBoolDiff(old, new *bool) DiffOption
WithOptionalBoolDiff creates a DiffOption that compares two *bool values, treating nil as false.
func WithOptionalStringDiff ¶ added in v0.19.1012
func WithOptionalStringDiff(old, new *string) DiffOption
WithOptionalStringDiff creates a DiffOption that compares two *string values, treating nil as empty string.
func WithStringDiff ¶
func WithStringDiff(old, new string) DiffOption
func WithStringSliceDiff ¶ added in v0.19.1012
func WithStringSliceDiff(old, new []string) DiffOption
WithStringSliceDiff creates a DiffOption that compares two string slices by sorting and joining them.
type DiffSummary ¶
type StringDiffer ¶
type StringDiffer struct {
// contains filtered or unexported fields
}
func (*StringDiffer) Diff ¶
func (d *StringDiffer) Diff() (string, Op)