go-cmp

Package for comparing Go values in tests

  • Owner: google/go-cmp
  • Platform:
  • License:: BSD 3-Clause "New" or "Revised" License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Package for equality of Go values

GoDoc
Build Status

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.

Install

go get -u github.com/google/go-cmp/cmp

License

BSD - See LICENSE file

Main metrics

Overview
Name With Ownergoogle/go-cmp
Primary LanguageGo
Program languageGo (Language Count: 1)
Platform
License:BSD 3-Clause "New" or "Revised" License
所有者活动
Created At2017-07-07 19:28:22
Pushed At2025-02-21 20:41:08
Last Commit At2025-01-14 10:15:44
Release Count18
Last Release Namev0.7.0 (Posted on )
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count4.4k
Watchers Count28
Fork Count216
Commits Count176
Has Issues Enabled
Issues Count175
Issue Open Count40
Pull Requests Count168
Pull Requests Open Count6
Pull Requests Close Count26
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private