1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Merge arrays!

This commit is contained in:
Mike Farah
2020-01-05 17:28:24 +13:00
parent 1aa5ec1d40
commit 1f7f1b0def
5 changed files with 29 additions and 17 deletions

View File

@@ -34,11 +34,20 @@ func DebugNode(value *yaml.Node) {
}
func PathStackToString(pathStack []interface{}) string {
return MergePathStackToString(pathStack, false)
}
func MergePathStackToString(pathStack []interface{}, appendArrays bool) string {
var sb strings.Builder
for index, path := range pathStack {
switch path.(type) {
case int:
sb.WriteString(fmt.Sprintf("[%v]", path))
if appendArrays {
sb.WriteString("[+]")
} else {
sb.WriteString(fmt.Sprintf("[%v]", path))
}
default:
sb.WriteString(fmt.Sprintf("%v", path))
}