commit | 3177a94b4e99d833e6c0d9f864faeb482f8a7f6d | [log] [tgz] |
---|---|---|
author | Joe Tsai <joetsai@digital-static.net> | Mon Mar 11 18:07:37 2019 -0700 |
committer | GitHub <noreply@github.com> | Mon Mar 11 18:07:37 2019 -0700 |
tree | 6ee4458d84d5f5724989dc9b65ec646909418cb8 | |
parent | 2940eda701e08ed0bd3cda4a6c69efb50af6db51 [diff] |
Export the Reporter API (#123) The Reporter option allows users to hook in their own custom reporters to programatically interpret the diff structure. The Reporter API uses a push/pop mechanism, which is strictly more powerful than an API that only calls report on leaf nodes. The Reporter.Report method takes in a Result type to provide flexibility in what properties can be reported in the future since new properties can be added, but new methods cannot be easily added to the reporter interface.
This package is intended to be a more powerful and safer alternative to reflect.DeepEqual
for comparing whether two values are semantically equal.
The primary features of cmp
are:
When the default behavior of equality does not suit the needs of the test, custom equality functions can override the equality operation. For example, an equality function may report floats as equal so long as they are within some tolerance of each other.
Types that have an Equal
method may use that method to determine equality. This allows package authors to determine the equality operation for the types that they define.
If no custom equality functions are used and no Equal
method is defined, equality is determined by recursively comparing the primitive kinds on both values, much like reflect.DeepEqual
. Unlike reflect.DeepEqual
, unexported fields are not compared by default; they result in panics unless suppressed by using an Ignore
option (see cmpopts.IgnoreUnexported
) or explicitly compared using the AllowUnexported
option.
See the GoDoc documentation for more information.
This is not an official Google product.
go get -u github.com/google/go-cmp/cmp
BSD - See LICENSE file