MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / compareValues

Function compareValues

cft/diff/compare.go:15–38  ·  view source on GitHub ↗
(old, new interface{})

Source from the content-addressed store, hash-verified

13}
14
15func compareValues(old, new interface{}) Diff {
16 if reflect.TypeOf(old) != reflect.TypeOf(new) {
17
18 // In YAML there is no difference between "" and null
19 if old == "" && new == nil {
20 return value{new, Unchanged}
21 }
22
23 return value{new, Changed}
24 }
25
26 switch v := old.(type) {
27 case []interface{}:
28 return compareSlices(v, new.([]interface{}))
29 case map[string]interface{}:
30 return CompareMaps(v, new.(map[string]interface{}))
31 default:
32 if !reflect.DeepEqual(old, new) {
33 return value{new, Changed}
34 }
35 }
36
37 return value{old, Unchanged}
38}
39
40func compareSlices(old, new []interface{}) Diff {
41 max := int(math.Max(float64(len(old)), float64(len(new))))

Callers 8

format_test.goFile · 0.85
compareSlicesFunction · 0.85
CompareMapsFunction · 0.85
ExampleValueFunction · 0.85
ExampleSliceFunction · 0.85
ExampleMapFunction · 0.85
ExampleNewFunction · 0.85
testCompareFunction · 0.85

Calls 2

compareSlicesFunction · 0.85
CompareMapsFunction · 0.85

Tested by 5

ExampleValueFunction · 0.68
ExampleSliceFunction · 0.68
ExampleMapFunction · 0.68
ExampleNewFunction · 0.68
testCompareFunction · 0.68