Merge branch 'main' of https://git.wamblee.org/public/gotools
This commit is contained in:
commit
f52507aa8f
@ -20,15 +20,19 @@ func subtract(yaml2 yaml.MapSlice, yaml1 yaml.MapSlice) yaml.MapSlice {
|
||||
v2 := item.Value
|
||||
v1 := yaml1.ToMap()[k]
|
||||
switch {
|
||||
case v2 != nil && v1 == nil:
|
||||
res = append(res, item)
|
||||
case reflect.DeepEqual(v1, v2):
|
||||
// delete is implicit by not copying to the output
|
||||
case Type(v1) == Map && Type(v2) == Map:
|
||||
case reflect.TypeOf(v1) == reflect.TypeOf(yaml.MapSlice{}) &&
|
||||
reflect.TypeOf(v2) == reflect.TypeOf(yaml.MapSlice{}):
|
||||
diff := subtract(v2.(yaml.MapSlice), v1.(yaml.MapSlice))
|
||||
if len(diff) > 0 {
|
||||
res = append(res, item)
|
||||
mi := yaml.MapItem{Key: k, Value: diff}
|
||||
res = append(res, mi)
|
||||
}
|
||||
case Type(v1) == Slice && Type(v2) == Slice:
|
||||
|
||||
// To be improved can be really confusing.
|
||||
v2set := make(map[string]bool)
|
||||
v1set := make(map[string]bool)
|
||||
stringToValue := make(map[any]any)
|
||||
|
Loading…
Reference in New Issue
Block a user