compare

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 2 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 {
	Field    string      // values of which field are different?
	Expected interface{} // expected value
	Actual   interface{} // actual value
}

the diff between the expected and the actual on exactly the same field if Field remains empty, that means the very root

func Compare

func Compare(expected, actual interface{}) (diffs []Diff, err error)

compare the given data, and returns the specific diffs if some expected's field does not appear in actual, an error would be thrown immediately NOTE: only public fields could be considered This function is supposed to be able to 1. compare fields recursively; 2. handle circular reference.

This function CANNOT 1. be thread-safe. 2. expected and actual are not exactly the same type (fields in expected is not consistent with actual)

Jump to

Keyboard shortcuts

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