diff

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Example
a := SampleStruct{
	A: 1,
	B: "b1",
	C: OtherStruct{
		A: []OtherStruct{{D: 1}, {D: 2}, {D: 3}},
		D: 0,
		E: false,
	},
	D: &OtherStruct{},
}

b := SampleStruct{
	A: 2,
	B: "b2",
	C: OtherStruct{
		A: []OtherStruct{{D: 1}, {D: 2}, {D: 4}},
		D: 0,
		E: false,
	},
	D: nil,
}

diffs := diff.Diffs(a, b)
for _, d := range diffs {
	fmt.Printf("%v\n\n", d)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonDiff

type CommonDiff struct {
	A interface{}
	B interface{}
}

CommonDiff is a simple difference error between two values A and B.

func (CommonDiff) Error

func (cd CommonDiff) Error() string

type Diff

type Diff struct {
	Path  []string
	Value error
}

Diff is a structure pointing a difference on a variable Path (Deep navigation on attributes and indexes). A difference is reported in the Value attribute as un error.

func Diffs

func Diffs(a, b interface{}) (diffs []Diff)

Diffs function returns all extracted differences between to variables a and b. It copies most of the standard reflect.DeepEq algorithm (getting around some unexported capabilities).

type FuncDiff

type FuncDiff CommonDiff

TypeDiff is a function difference error between two values A and B. (all functions are considered different).

func (FuncDiff) Error

func (fd FuncDiff) Error() string

type InvalidDiff

type InvalidDiff struct {
	A bool
	B bool
}

InvalidDiff reports that one or both of the values A and B are in an Invalid State.

func (InvalidDiff) Error

func (id InvalidDiff) Error() string

type KeyNotFoundDiff

type KeyNotFoundDiff struct {
	Key string
	A   bool
	B   bool
}

KeyNotFoundDiff reports that a Key exists only on A or B.

func (KeyNotFoundDiff) Error

func (kd KeyNotFoundDiff) Error() string

type LenDiff

type LenDiff struct {
	CommonDiff
	Value int
}

LenDiff reports a length different between A and B.

func (LenDiff) Error

func (ld LenDiff) Error() string

type TypeDiff

type TypeDiff CommonDiff

TypeDiff is a type difference error between two values A and B.

func (TypeDiff) Error

func (td TypeDiff) Error() string

Jump to

Keyboard shortcuts

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