Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/google/go-cmp
Package for comparing Go values in tests
https://github.com/google/go-cmp
equality go testing
Last synced: 3 days ago
JSON representation
Package for comparing Go values in tests
- Host: GitHub
- URL: https://github.com/google/go-cmp
- Owner: google
- License: bsd-3-clause
- Created: 2017-07-07T19:28:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T16:55:03.000Z (about 2 months ago)
- Last Synced: 2024-10-29T19:58:52.533Z (about 1 month ago)
- Topics: equality, go, testing
- Language: Go
- Homepage:
- Size: 580 KB
- Stars: 4,200
- Watchers: 28
- Forks: 209
- Open Issues: 39
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-cmp - Package for comparing Go values in tests. (Testing / Testing Frameworks)
- awesome-go - google/go-cmp
- zero-alloc-awesome-go - go-cmp - Package for comparing Go values in tests. (Testing / HTTP Clients)
- awesome-ccamel - google/go-cmp - Package for comparing Go values in tests (Go)
- awesome-tools - go-cmp - Package for comparing Go values in tests. Awesome alternative to `reflect.DeepEqual`. (Programming / Go)
- awesome-go - go-cmp - Package for comparing Go values in tests. Stars:`4.2K`. (Testing / Testing Frameworks)
- awesome-golang-repositories - go-cmp
- awesome-go - go-cmp - Package for comparing Go values in tests - ★ 695 (Testing)
- awesome-go-extra - go-cmp - 07-07T19:28:22Z|2022-08-14T07:22:46Z| (Testing / Testing Frameworks)
README
# Package for equality of Go values
[![GoDev](https://img.shields.io/static/v1?label=godev&message=reference&color=00add8)][godev]
[![Build Status](https://github.com/google/go-cmp/actions/workflows/test.yml/badge.svg?branch=master)][actions]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][godev] for more information.
This is not an official Google product.
[godev]: https://pkg.go.dev/github.com/google/go-cmp/cmp
[actions]: https://github.com/google/go-cmp/actions## Install
```
go get -u github.com/google/go-cmp/cmp
```## License
BSD - See [LICENSE][license] file
[license]: https://github.com/google/go-cmp/blob/master/LICENSE