diff

package
v1.22.5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenDelta

func FlattenDelta(delta Delta) map[string]*DiffDescriptor

func NewDiffCollector

func NewDiffCollector(opts ...Option) *diffCollector

Types

type AdditionalDataMaker

type AdditionalDataMaker func(op Operation, x, y reflect.Value, path string, step cmp.PathStep) interface{}

type Delta

type Delta []*DiffDescriptor

func EvalDiff

func EvalDiff(left, right map[string]interface{}, opts ...Option) (bool, Delta)

func ExtensionDelta added in v1.22.0

func ExtensionDelta(delta Delta) Delta

func ReplaceArray added in v1.22.0

func ReplaceArray(delta Delta) Delta

type DiffDescriptor

type DiffDescriptor struct {
	OldValue       interface{} `json:"oldValue,omitempty"`
	NewValue       interface{} `json:"newValue,omitempty"`
	Path           string      `json:"path"`
	Operation      Operation   `json:"operation"`
	AdditionalData interface{} `json:"additionalData,omitempty"`
	OldIndex       *int        `json:"oldIndex,omitempty"`
	NewIndex       *int        `json:"newIndex,omitempty"`
}

type Operation

type Operation string
const (
	Add    Operation = "ADD"
	Delete Operation = "DELETE"
	Change Operation = "CHANGE"

	ArrayAdd    Operation = "ARRAY_ADD"
	ArrayDelete Operation = "ARRAY_DELETE"
	ArrayChange Operation = "ARRAY_CHANGE"
	ArraySwap   Operation = "ARRAY_SWAP"
)

type Option

type Option func(dc *diffCollector)

func MakeAdditionalData

func MakeAdditionalData(f AdditionalDataMaker) Option

Jump to

Keyboard shortcuts

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