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)
| 88 | // If index is invalid, this returns a non-nil [PathStep] |
| 89 | // that reports a nil [PathStep.Type]. |
| 90 | func (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. |
no outgoing calls