1 # Package for equality of Go values
3 [![GoDev](https://img.shields.io/static/v1?label=godev&message=reference&color=00add8)][godev]
4 [![Build Status](https://travis-ci.org/google/go-cmp.svg?branch=master)][travis]
6 This package is intended to be a more powerful and safer alternative to
7 `reflect.DeepEqual` for comparing whether two values are semantically equal.
9 The primary features of `cmp` are:
11 * When the default behavior of equality does not suit the needs of the test,
12 custom equality functions can override the equality operation.
13 For example, an equality function may report floats as equal so long as they
14 are within some tolerance of each other.
16 * Types that have an `Equal` method may use that method to determine equality.
17 This allows package authors to determine the equality operation for the types
20 * If no custom equality functions are used and no `Equal` method is defined,
21 equality is determined by recursively comparing the primitive kinds on both
22 values, much like `reflect.DeepEqual`. Unlike `reflect.DeepEqual`, unexported
23 fields are not compared by default; they result in panics unless suppressed
24 by using an `Ignore` option (see `cmpopts.IgnoreUnexported`) or explicitly
25 compared using the `AllowUnexported` option.
27 See the [documentation][godev] for more information.
29 This is not an official Google product.
31 [godev]: https://pkg.go.dev/github.com/google/go-cmp/cmp
32 [travis]: https://travis-ci.org/google/go-cmp
37 go get -u github.com/google/go-cmp/cmp
42 BSD - See [LICENSE][license] file
44 [license]: https://github.com/google/go-cmp/blob/master/LICENSE