Add the possibility to delete a full table from values

pull/4046/head
Nandor Kracser 7 years ago
parent 2d5e05b63c
commit 338344e37b

@ -316,6 +316,8 @@ func coalesceTables(dst, src map[string]interface{}) map[string]interface{} {
dst[key] = val
} else if istable(innerdst) {
coalesceTables(innerdst.(map[string]interface{}), val.(map[string]interface{}))
} else if isnull(innerdst) {
delete(dst, key)
} else {
log.Printf("warning: cannot overwrite table with non table for %s (%v)", key, val)
}
@ -388,6 +390,11 @@ func istable(v interface{}) bool {
return ok
}
// isnull is a special-purpose function to see if the present thing matches the definition of a YAML null.
func isnull(v interface{}) bool {
return v == "null" || v == "Null" || v == "NULL" || v == "~"
}
// 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".

Loading…
Cancel
Save