Fixed modify array issue!

This commit is contained in:
Mike Farah
2019-12-30 11:21:21 +13:00
parent 0652f67a91
commit 8a6af1720d
6 changed files with 82 additions and 41 deletions
+18
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"strconv"
"strings"
logging "gopkg.in/op/go-logging.v1"
yaml "gopkg.in/yaml.v3"
@@ -30,6 +31,23 @@ func DebugNode(value *yaml.Node) {
}
}
func PathStackToString(pathStack []interface{}) string {
var sb strings.Builder
for index, path := range pathStack {
switch path.(type) {
case int:
sb.WriteString(fmt.Sprintf("[%v]", path))
default:
sb.WriteString(fmt.Sprintf("%v", path))
}
if index < len(pathStack)-1 {
sb.WriteString(".")
}
}
return sb.String()
}
func guessKind(tail []string, guess yaml.Kind) yaml.Kind {
log.Debug("tail %v", tail)
if len(tail) == 0 && guess == 0 {