Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // FloatPrecision is the number of decimal places to round float values // to when comparing. FloatPrecision = 10 // MaxDiff specifies the maximum number of differences to return. MaxDiff = 10 // MaxDepth specifies the maximum levels of a struct to recurse into, // if greater than zero. If zero, there is no limit. MaxDepth = 0 // LogErrors causes errors to be logged to STDERR when true. LogErrors = false // CompareUnexportedFields causes unexported struct fields, like s in // T{s int}, to be compared when true. CompareUnexportedFields = false )
View Source
var ( // ErrMaxRecursion is logged when MaxDepth is reached. ErrMaxRecursion = errors.New("recursed to MaxDepth") // ErrTypeMismatch is logged when Equal passed two different types of values. ErrTypeMismatch = errors.New("variables are different reflect.Type") // ErrNotHandled is logged when a primitive Go kind is not handled. ErrNotHandled = errors.New("cannot compare the reflect.Kind") )
Functions ¶
func Equal ¶
func Equal(a, b interface{}) []string
Equal compares variables a and b, recursing into their structure up to MaxDepth levels deep (if greater than zero), and returns a list of differences, or nil if there are none. Some differences may not be found if an error is also returned.
If a type has an Equal method, like time.Equal, it is called to check for equality.
When comparing a struct, if a field has the tag `deep:"-"` then it will be ignored.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.