findPathChild finds the child with the given string representation in [NodeBase.FindPath].
(n Node, child string)
| 287 | |
| 288 | // findPathChild finds the child with the given string representation in [NodeBase.FindPath]. |
| 289 | func findPathChild(n Node, child string) int { |
| 290 | if child[0] == '[' && child[len(child)-1] == ']' { |
| 291 | idx, err := strconv.Atoi(child[1 : len(child)-1]) |
| 292 | if err != nil { |
| 293 | return idx |
| 294 | } |
| 295 | if idx < 0 { // from end |
| 296 | idx = len(n.AsTree().Children) + idx |
| 297 | } |
| 298 | return idx |
| 299 | } |
| 300 | return IndexByName(n.AsTree().Children, child) |
| 301 | } |
| 302 | |
| 303 | // Adding and Inserting Children: |
| 304 |
no test coverage detected