WithIndex is short for push index, convert to string, and pop. This is useful when you want the location of the index given a path buffer as a prefix. pb.Push("foo") pb.WithIndex(1) // return foo[1]
(i int)
| 134 | // pb.Push("foo") |
| 135 | // pb.WithIndex(1) // return foo[1] |
| 136 | func (b *PathBuffer) WithIndex(i int) string { |
| 137 | b.PushIndex(i) |
| 138 | tmp := b.String() |
| 139 | b.Pop() |
| 140 | return tmp |
| 141 | } |
| 142 | |
| 143 | // Len returns the length of the current path. |
| 144 | func (b *PathBuffer) Len() int { |