cmputil

package
v0.0.0-testrgm4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	// Path to the field that has difference separated by period. Array index and key are designated by square brackets.
	// For example, Annotations[12345].Data.Fields[0].ID
	Path  string
	Left  reflect.Value
	Right reflect.Value
}

func (*Diff) IsAddOperation

func (d *Diff) IsAddOperation() bool

IsAddOperation returns true when

  • Left does not have value and Right has
  • the kind of Left and Right is either reflect.Slice or reflect.Map and the length of Left is less than length of Right

In all other cases it returns false. NOTE: this is applicable to diff of Maps and Slices only

func (*Diff) IsDeleteOperation

func (d *Diff) IsDeleteOperation() bool

IsDeleteOperation returns true when

  • Right does not have value and Left has
  • the kind of Left and Right is either reflect.Slice or reflect.Map and the length of Right is less than length of Left

In all other cases it returns false. NOTE: this is applicable to diff of Maps and Slices only

func (*Diff) String

func (d *Diff) String() string

type DiffReport

type DiffReport []Diff

func (DiffReport) GetDiffsForField

func (r DiffReport) GetDiffsForField(path string) DiffReport

GetDiffsForField returns subset of the diffs which path starts with the provided path

func (DiffReport) Paths

func (r DiffReport) Paths() []string

Paths returns the slice of paths of the current DiffReport

func (DiffReport) String

func (r DiffReport) String() string

type DiffReporter

type DiffReporter struct {
	Diffs DiffReport
	// contains filtered or unexported fields
}

DiffReporter is a simple custom reporter that only records differences detected during comparison. Implements an interface required by cmp.Reporter option

func (*DiffReporter) PopStep

func (r *DiffReporter) PopStep()

func (*DiffReporter) PushStep

func (r *DiffReporter) PushStep(ps cmp.PathStep)

func (*DiffReporter) Report

func (r *DiffReporter) Report(rs cmp.Result)

Jump to

Keyboard shortcuts

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