go-cmp

Package for comparing Go values in tests

  • 所有者: google/go-cmp
  • 平台:
  • 许可证: BSD 3-Clause "New" or "Revised" License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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

主要指标

概览
名称与所有者google/go-cmp
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证BSD 3-Clause "New" or "Revised" License
所有者活动
创建于2017-07-07 19:28:22
推送于2025-02-21 20:41:08
最后一次提交2025-01-14 10:15:44
发布数18
最新版本名称v0.7.0 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数4.4k
关注者数28
派生数216
提交数176
已启用问题?
问题数175
打开的问题数40
拉请求数168
打开的拉请求数6
关闭的拉请求数26
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?