(data any, pp pathWithPos)
| 181 | } |
| 182 | |
| 183 | func getPathInternal(data any, pp pathWithPos) (any, error) { |
| 184 | if data == nil { |
| 185 | return nil, nil |
| 186 | } |
| 187 | if pp.Index >= len(pp.Path) { |
| 188 | return data, nil |
| 189 | } |
| 190 | pathElemAny := pp.Path[pp.Index] |
| 191 | switch pathElem := pathElemAny.(type) { |
| 192 | case string: |
| 193 | mapVal, ok := data.(map[string]any) |
| 194 | if !ok { |
| 195 | return nil, nil |
| 196 | } |
| 197 | return getPathInternal(mapVal[pathElem], pathWithPos{Path: pp.Path, Index: pp.Index + 1}) |
| 198 | case int: |
| 199 | if pathElem < 0 { |
| 200 | return nil, MakePathError("negative index", pp.Path, pp.Index) |
| 201 | } |
| 202 | arrVal, ok := data.([]any) |
| 203 | if !ok { |
| 204 | return nil, nil |
| 205 | } |
| 206 | if pathElem >= len(arrVal) { |
| 207 | return nil, nil |
| 208 | } |
| 209 | return getPathInternal(arrVal[pathElem], pathWithPos{Path: pp.Path, Index: pp.Index + 1}) |
| 210 | default: |
| 211 | return nil, MakePathTypeError(pp.Path, pp.Index) |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | type CombiningFunc func(curValue any, newValue any, pp pathWithPos, opts SetPathOpts) (any, error) |
| 216 |
no test coverage detected