commit | e250a55e913727afa4a4ccf87d716232288d9b5f | [log] [tgz] |
---|---|---|
author | Joe Tsai <joetsai@digital-static.net> | Wed Aug 30 23:29:42 2023 -0700 |
committer | GitHub <noreply@github.com> | Wed Aug 30 23:29:42 2023 -0700 |
tree | 447aa01319aa2580f1a425729b8654133e573db7 | |
parent | 8a3e8dd7458e5d9ba6b4317a4b1423b4910d4014 [diff] |
Use of hotlinking of Go identifiers (#337) GoDoc now supports hot linking to specific Go identifiers. Use that feature to enhance the usability of cmp docs. Since cmp lacks a direct dependency on cmpopts, you are forced to use the fully-qualified import path to references identifiers in the cmpopts package. It can future improvements to the go/doc to handle this case, either by rendering the doc with short form, or by detecting the use of cmpopts from the unit tests as well (since those can break circular dependencies).
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 documentation for more information.
This is not an official Google product.
go get -u github.com/google/go-cmp/cmp
BSD - See LICENSE file