Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/google/go-cmp
/ functions
Functions
428 in github.com/google/go-cmp
⨍
Functions
428
◇
Types & classes
226
↓ 35 callers
Method
Type
Type is the resulting type after performing the path step.
cmp/path.go:43
↓ 21 callers
Method
Equal
Equal reports whether the two trees are structurally identical. Nested textRecord.Diff and textRecord.Comment fields are compared.
cmp/report_text.go:71
↓ 19 callers
Function
Comparer
Comparer returns an [Option] that determines whether two values are equal to each other. The comparer f must be a function "func(T, T) bool" and is i
cmp/options.go:347
↓ 18 callers
Method
Len
Len reports the length in bytes of a single-line version of the tree. Nested textRecord.Diff and textRecord.Comment fields are ignored.
cmp/report_text.go:68
↓ 17 callers
Method
Index
Index returns the ith step in the Path and supports negative indexing. A negative index starts counting from the tail of the Path such that -1 refers
cmp/path.go:90
↓ 17 callers
Method
IsNil
IsNil reports whether the pointer is nil.
cmp/internal/value/pointer.go:27
↓ 13 callers
Function
FilterPath
FilterPath returns a new [Option] where opt is only evaluated if filter f returns true for the current [Path] in the value tree. This filter is calle
cmp/options.go:118
↓ 13 callers
Function
Transformer
Transformer returns an [Option] that applies a transformation function that converts values of a certain type into that of another. The transformer f
cmp/options.go:280
↓ 11 callers
Function
Equal
TODO(≥go1.18): Use any instead of interface{}. Equal reports whether x and y are equal by recursively applying the following rules in the given order
cmp/compare.go:95
↓ 11 callers
Function
FilterValues
FilterValues returns a new [Option] where opt is only evaluated if filter f, which is a function of the form "func(T, T) bool", returns true for the c
cmp/options.go:159
↓ 11 callers
Method
Name
Name is the name of the [Transformer].
cmp/path.go:311
↓ 11 callers
Method
String
()
cmp/path.go:40
↓ 10 callers
Method
Errorf
(format string, args ...interface{})
cmp/cmpopts/example_test.go:130
↓ 9 callers
Function
Ignore
Ignore is an [Option] that causes all comparisons to be ignored. This value is intended to be combined with [FilterPath] or [FilterValues]. It is an e
cmp/options.go:198
↓ 9 callers
Function
assert
(ok bool)
cmp/report.go:50
↓ 9 callers
Method
compareAny
(step PathStep)
cmp/compare.go:238
↓ 9 callers
Method
report
(eq bool, rf resultFlags)
cmp/compare.go:582
↓ 8 callers
Function
IsType
IsType reports whether the reflect.Type is of the specified function type.
cmp/internal/function/func.go:38
↓ 8 callers
Function
NameOf
NameOf returns the name of the function value.
cmp/internal/function/func.go:71
↓ 6 callers
Method
Last
Last returns the last [PathStep] in the Path. If the path is empty, this returns a non-nil [PathStep] that reports a nil [PathStep.Type].
cmp/path.go:81
↓ 6 callers
Method
Values
Values is the resulting values after performing the path step. The type of each valid value is guaranteed to be identical to Type. In some cases, one
cmp/path.go:58
↓ 6 callers
Method
verbosity
()
cmp/report_compare.go:69
↓ 5 callers
Function
AllowUnexported
AllowUnexported returns an [Option] that allows [Equal] to forcibly introspect unexported fields of the specified struct types. See [Exporter] for th
cmp/options.go:422
↓ 5 callers
Function
Diff
Diff returns a human-readable report of the differences between two values: y - x. It returns an empty string if and only if Equal returns true for th
cmp/compare.go:115
↓ 5 callers
Function
Difference
Difference reports whether two lists of lengths nx and ny are equal given the definition of equality provided as f. This function returns an edit-scr
cmp/internal/diff/diff.go:138
↓ 5 callers
Method
IsZero
()
cmp/report_text.go:374
↓ 5 callers
Method
Key
Key is the value of the map key.
cmp/path.go:276
↓ 5 callers
Function
PointerOf
PointerOf returns a Pointer from v, which must be a reflect.Ptr, reflect.Slice, or reflect.Map.
cmp/internal/value/pointer.go:20
↓ 5 callers
Method
Pop
Pop ascends from pointers vx and vy.
cmp/path.go:381
↓ 4 callers
Method
Append
(ds diffStats)
cmp/report_text.go:383
↓ 4 callers
Method
NumDiff
()
cmp/report_text.go:379
↓ 4 callers
Method
Push
Push indicates intent to descend into pointers vx and vy where visited reports whether either has been seen before. If visited before, equal reports w
cmp/path.go:366
↓ 4 callers
Method
Similar
Similar indicates whether two symbols are similar and may be represented by using the Modified type. As a special case, we consider binary comparisons
cmp/internal/diff/diff.go:117
↓ 4 callers
Method
String
()
cmp/internal/testprotos/protos.go:16
↓ 4 callers
Function
TypeString
TypeString is nearly identical to reflect.Type.String, but has an additional option to specify that full type names be used.
cmp/internal/value/name.go:16
↓ 4 callers
Method
WithTypeMode
(t typeMode)
cmp/report_compare.go:60
↓ 4 callers
Method
filter
filter applies all filters and returns the option that remains. Each option may only read s.curPath and call s.callTTBFunc. An Options is returned on
cmp/options.go:32
↓ 3 callers
Method
AppendEllipsis
AppendEllipsis appends a new ellipsis node to the list if none already exists at the end. If cs is non-zero it coalesces the statistics with the previ
cmp/report_text.go:153
↓ 3 callers
Method
FormatType
FormatType prints the type as if it were wrapping s. This may return s as-is depending on the current type and TypeMode mode.
cmp/report_reflect.go:51
↓ 3 callers
Function
IgnoreUnexported
IgnoreUnexported returns an [cmp.Option] that only ignores the immediate unexported fields of a struct, including anonymous fields of unexported types
cmp/cmpopts/ignore.go:119
↓ 3 callers
Method
Option
Option returns the originally constructed [Transformer] option. The == operator can be used to detect the exact option used.
cmp/path.go:318
↓ 3 callers
Function
SortKeys
SortKeys sorts a list of map keys, deduplicating keys if necessary. The type of each value must be comparable.
cmp/internal/value/sort.go:16
↓ 3 callers
Method
callTTBFunc
(f, x, y reflect.Value)
cmp/compare.go:347
↓ 3 callers
Function
compareByte
compareByte returns a Result where the result is Equal if x == y, similar if x and y differ only in casing, and different otherwise.
cmp/internal/diff/diff_test.go:383
↓ 3 callers
Method
formatExpandedTo
formatExpandedTo formats the contents of the tree as a multi-line string to the provided buffer. In order for column alignment to operate well, format
cmp/report_text.go:91
↓ 3 callers
Function
formatHex
formatHex prints u as a hexadecimal integer in Go notation.
cmp/report_reflect.go:393
↓ 3 callers
Function
formatPointer
formatPointer prints the address of the pointer.
cmp/report_references.go:22
↓ 3 callers
Method
less
(v reflect.Value, i, j int)
cmp/cmpopts/sort.go:80
↓ 3 callers
Function
newInt
TODO(≥go1.18): Define a generic function that boxes a value on the heap.
cmp/compare_test.go:108
↓ 3 callers
Method
stats
stats returns a histogram of the number of each type of edit operation.
cmp/internal/diff/diff.go:62
↓ 2 callers
Function
BoolResult
BoolResult returns a Result that is either Equal or not Equal.
cmp/internal/diff/diff.go:100
↓ 2 callers
Method
CanFormatDiffSlice
CanFormatDiffSlice reports whether we support custom formatting for nodes that are slices of primitive kinds or strings.
cmp/report_slices.go:22
↓ 2 callers
Function
EquateErrors
EquateErrors returns a [cmp.Comparer] option that determines errors to be equal if [errors.Is] reports them to match. The [AnyError] error can be used
cmp/cmpopts/equate.go:138
↓ 2 callers
Method
FormatDiff
FormatDiff converts a valueNode tree into a textNode tree, where the later is a textual representation of the differences detected in the former.
cmp/report_compare.go:98
↓ 2 callers
Method
FormatDiffSlice
FormatDiffSlice prints a diff for the slices (or strings) represented by v. This provides custom-tailored logic to make printing of differences in tex
cmp/report_slices.go:90
↓ 2 callers
Method
FormatValue
FormatValue prints the reflect.Value, taking extra care to avoid descending into pointers already in ptrs. As pointers are visited, ptrs is also updat
cmp/report_reflect.go:114
↓ 2 callers
Function
IgnoreFields
IgnoreFields returns an [cmp.Option] that ignores fields of the given names on a single struct type. It respects the names of exported fields that are
cmp/cmpopts/ignore.go:24
↓ 2 callers
Function
IgnoreInterfaces
IgnoreInterfaces returns an [cmp.Option] that ignores all values or references of values assignable to certain interface types. These interfaces are s
cmp/cmpopts/ignore.go:66
↓ 2 callers
Function
MakeGatewayInfo
()
cmp/example_test.go:320
↓ 2 callers
Method
Next
Next increments the state and reports whether a check should be performed. Checks occur every Nth function call, where N is a triangular number: 0
cmp/compare.go:651
↓ 2 callers
Method
PopStep
()
cmp/options.go:517
↓ 2 callers
Method
PushStep
(PathStep)
cmp/options.go:515
↓ 2 callers
Method
Report
(Result)
cmp/options.go:516
↓ 2 callers
Function
Reporter
Reporter is an [Option] that can be passed to [Equal]. When [Equal] traverses the value trees, it calls PushStep as it descends into each node in the
cmp/options.go:486
↓ 2 callers
Method
String
String returns the string representation of the text tree. It is not guaranteed that len(x.String()) == x.Len(), nor that x.String() == y.String() imp
cmp/report_text.go:75
↓ 2 callers
Method
Update
()
cmp/internal/diff/debug_enable.go:100
↓ 2 callers
Method
append
(t EditType)
cmp/internal/diff/diff.go:377
↓ 2 callers
Method
appendChar
(b []byte, c byte)
cmp/report_text.go:56
↓ 2 callers
Method
appendIndent
(b []byte, d diffMode)
cmp/report_text.go:24
↓ 2 callers
Function
detectRaces
(c chan<- reflect.Value, f reflect.Value, vs ...reflect.Value)
cmp/compare.go:366
↓ 2 callers
Function
flattenOptions
flattenOptions copies all options in src to dst as a flat list. Only coreOptions and Options containing coreOptions are allowed.
cmp/options.go:540
↓ 2 callers
Method
formatCompactTo
formatCompactTo formats the contents of the tree as a single-line string to the provided buffer. Any nested textRecord.Diff and textRecord.Comment fie
cmp/report_text.go:87
↓ 2 callers
Function
formatMapKey
formatMapKey formats v as if it were a map key. The result is guaranteed to be a single line.
cmp/report_reflect.go:359
↓ 2 callers
Function
formatString
formatString prints s as a double-quoted or backtick-quoted string.
cmp/report_reflect.go:373
↓ 2 callers
Function
generateStrings
(n int, px, py, pm float32, seed int64)
cmp/internal/diff/diff_test.go:310
↓ 2 callers
Function
isExported
isExported reports whether the identifier is exported.
cmp/path.go:387
↓ 2 callers
Function
isExported
isExported reports whether the identifier is exported.
cmp/cmpopts/ignore.go:146
↓ 2 callers
Method
less
(v reflect.Value, i, j int)
cmp/cmpopts/sort.go:144
↓ 2 callers
Function
makeAddressable
makeAddressable returns a value that is always addressable. It returns the input verbatim if it is already addressable, otherwise it creates a new val
cmp/compare.go:664
↓ 2 callers
Function
newState
(opts []Option)
cmp/compare.go:188
↓ 2 callers
Function
newStructFilter
(typ interface{}, names ...string)
cmp/cmpopts/struct_filter.go:35
↓ 2 callers
Function
normalizeOption
normalizeOption normalizes the input options such that all Options groups are flattened and groups with a single element are reduced to that element.
cmp/options.go:527
↓ 2 callers
Method
print
(d time.Duration)
cmp/internal/diff/debug_enable.go:117
↓ 2 callers
Function
retrieveUnexportedField
retrieveUnexportedField uses unsafe to forcibly retrieve any field from a struct such that the value has read-write permissions. The parent struct, v
cmp/export.go:18
↓ 2 callers
Function
rootStep
rootStep constructs the first path step. If x and y have differing types, then they are stored within an empty interface type.
cmp/compare.go:141
↓ 2 callers
Method
statelessCompare
statelessCompare compares two values and returns the result. This function is stateless in that it does not alter the current result, or output to any
cmp/compare.go:223
↓ 2 callers
Function
testStrings
(t *testing.T, x, y string)
cmp/internal/diff/diff_test.go:340
↓ 2 callers
Function
verbosityPreset
verbosityPreset modifies the verbosity settings given an index between 0 and maxVerbosityPreset, inclusive.
cmp/report_compare.go:84
↓ 1 callers
Function
AcyclicTransformer
AcyclicTransformer returns a [cmp.Transformer] with a filter applied that ensures that the transformer cannot be recursively applied upon its own outp
cmp/cmpopts/xform.go:33
↓ 1 callers
Method
Begin
(nx, ny int, f EqualFunc, p1, p2 *EditScript)
cmp/internal/diff/debug_enable.go:72
↓ 1 callers
Method
ByFunc
ByFunc reports whether a [Comparer] function determined equality.
cmp/options.go:459
↓ 1 callers
Method
ByIgnore
ByIgnore reports whether the node is equal because it was ignored. This never reports true if [Result.Equal] reports false.
cmp/options.go:449
↓ 1 callers
Method
ByMethod
ByMethod reports whether the Equal method determined equality.
cmp/options.go:454
↓ 1 callers
Method
Check
Check scans the Path for any recursive transformers and panics when any recursive transformers are detected. Note that the presence of a recursive Tra
cmp/compare.go:605
↓ 1 callers
Method
Dist
Dist is the Levenshtein distance and is guaranteed to be 0 if and only if lists X and Y are equal.
cmp/internal/diff/diff.go:82
↓ 1 callers
Function
EquateApprox
EquateApprox returns a [cmp.Comparer] option that determines float32 or float64 values to be equal if they are within a relative fraction or absolute
cmp/cmpopts/equate.go:50
↓ 1 callers
Function
EquateApproxTime
EquateApproxTime returns a [cmp.Comparer] option that determines two non-zero [time.Time] values to be equal if they are within some margin of one ano
cmp/cmpopts/equate.go:99
↓ 1 callers
Function
EquateComparable
EquateComparable returns a [cmp.Option] that determines equality of comparable types by directly comparing them using the == operator in Go. The types
cmp/cmpopts/equate.go:166
↓ 1 callers
Function
EquateEmpty
EquateEmpty returns a [cmp.Comparer] option that determines all maps and slices with a length of zero to be equal, regardless of whether they are nil.
cmp/cmpopts/equate.go:24
↓ 1 callers
Function
EquateNaNs
EquateNaNs returns a [cmp.Comparer] option that determines float32 and float64 NaN values to be equal. EquateNaNs can be used in conjunction with [Eq
cmp/cmpopts/equate.go:81
next →
1–100 of 428, ranked by callers