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

Method Index

cmp/path.go:90–98  ·  view source on GitHub ↗

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 to the last step, -2 refers to the second-to-last step, and so on. If index is invalid, this returns a non-nil [PathStep] that reports a nil [PathStep

(i int)

Source from the content-addressed store, hash-verified

88// If index is invalid, this returns a non-nil [PathStep]
89// that reports a nil [PathStep.Type].
90func (pa Path) Index(i int) PathStep {
91 if i < 0 {
92 i = len(pa) + i
93 }
94 if i < 0 || i >= len(pa) {
95 return pathStep{}
96 }
97 return pa[i]
98}
99
100// String returns the simplified path to a node.
101// The simplified path only contains struct field accesses.

Callers 15

LastMethod · 0.95
FormatDiffSliceMethod · 0.45
formatDiffSliceMethod · 0.45
compareSliceMethod · 0.45
mustParseGoldenFunction · 0.45
comparerTestsFunction · 0.45
applyMethod · 0.45
FormatValueMethod · 0.45
sortMethod · 0.45
lessMethod · 0.45
sortMethod · 0.45
checkSortMethod · 0.45

Calls

no outgoing calls

Tested by 2

mustParseGoldenFunction · 0.36
comparerTestsFunction · 0.36