PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. Given the following YAML data the value at path "chapter.one.title" is "Loomings". chapter:
(path string)
| 142 | // one: |
| 143 | // title: "Loomings" |
| 144 | func (v Values) PathValue(path string) (any, error) { |
| 145 | if path == "" { |
| 146 | return nil, errors.New("YAML path cannot be empty") |
| 147 | } |
| 148 | return v.pathValue(parsePath(path)) |
| 149 | } |
| 150 | |
| 151 | func (v Values) pathValue(path []string) (any, error) { |
| 152 | if len(path) == 1 { |