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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?