MCPcopy
hub / github.com/google/go-cmp

github.com/google/go-cmp @v0.7.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.7.0 ↗
654 symbols 1,482 edges 42 files 189 documented · 29%
README

Package for equality of Go values

GoDev 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 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

Extension points exported contracts — how you extend this code

PathStep (Interface)
PathStep is a union-type for specific operations to traverse a value's tree structure. Users of this package never need [7 …
cmp/path.go
Option (Interface)
Option configures for specific behavior of [Equal] and [Diff]. In particular, the fundamental Option functions ([Ignore] [12 …
cmp/options.go
InterfaceA (Interface)
(no doc) [4 implementers]
cmp/internal/teststructs/structs.go
Iface1 (Interface)
(no doc)
cmp/compare_test.go
EmptyInterface (Interface)
(no doc)
cmp/cmpopts/util_test.go
EqualFunc (FuncType)
EqualFunc reports whether the symbols at indexes ix and iy are equal. When called by Difference, the index is guaranteed
cmp/internal/diff/diff.go
Iface2 (Interface)
(no doc)
cmp/compare_test.go
AssignA (FuncType)
Equal method (with interface argument) on non-satisfying receiver
cmp/internal/teststructs/structs.go

Core symbols most depended-on inside this repo

Type
called by 74
cmp/path.go
Comparer
called by 60
cmp/options.go
Equal
called by 50
cmp/report_text.go
Len
called by 49
cmp/report_text.go
AllowUnexported
called by 44
cmp/options.go
IsNil
called by 36
cmp/internal/value/pointer.go
Index
called by 35
cmp/path.go
Transformer
called by 33
cmp/options.go

Shape

Method 298
Struct 154
Function 130
TypeAlias 55
Interface 14
FuncType 3

Languages

Go100%

Modules by API surface

cmp/internal/teststructs/structs.go69 symbols
cmp/options.go61 symbols
cmp/path.go58 symbols
cmp/internal/teststructs/project4.go49 symbols
cmp/compare_test.go49 symbols
cmp/report_text.go38 symbols
cmp/internal/testprotos/protos.go31 symbols
cmp/compare.go26 symbols
cmp/cmpopts/equate.go26 symbols
cmp/internal/teststructs/project3.go19 symbols
cmp/internal/diff/diff.go19 symbols
cmp/cmpopts/util_test.go19 symbols

For agents

$ claude mcp add go-cmp \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact