Documentation ¶
Overview ¶
Package deep provides function deep.Equal which is like reflect.DeepEqual but returns a list of differences. This is helpful when comparing complex types like structures and maps.
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. MaxDepth = 10 // 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 comparsed 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, 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.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.