mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
DRYd code
This commit is contained in:
parent
7db31006da
commit
805729e4f7
@ -20,10 +20,7 @@ func write(context map[interface{}]interface{}, head string, tail []string, valu
|
|||||||
|
|
||||||
func readMap(context map[interface{}]interface{}, head string, tail []string) interface{} {
|
func readMap(context map[interface{}]interface{}, head string, tail []string) interface{} {
|
||||||
value := context[head]
|
value := context[head]
|
||||||
if len(tail) > 0 {
|
return calculateValue(value, tail)
|
||||||
return recurse(value, tail[0], tail[1:len(tail)])
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func recurse(value interface{}, head string, tail []string) interface{} {
|
func recurse(value interface{}, head string, tail []string) interface{} {
|
||||||
@ -50,10 +47,8 @@ func readArray(array []interface{}, head int64, tail []string) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
value := array[head]
|
value := array[head]
|
||||||
if len(tail) > 0 {
|
|
||||||
return recurse(value, tail[0], tail[1:len(tail)])
|
return calculateValue(value, tail)
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readArraySplat(array []interface{}, tail []string) interface{} {
|
func readArraySplat(array []interface{}, tail []string) interface{} {
|
||||||
|
Loading…
Reference in New Issue
Block a user