MCPcopy Create free account
hub / github.com/aws-samples/devsecops-quickstart / merge

Function merge

devsecops_quickstart/opa_scan/pkg/utils/utils.go:17–32  ·  view source on GitHub ↗
(dst, src map[string]interface{}, depth int)

Source from the content-addressed store, hash-verified

15}
16
17func merge(dst, src map[string]interface{}, depth int) map[string]interface{} {
18 if depth > MaxDepth {
19 panic("too deep!")
20 }
21 for key, srcVal := range src {
22 if dstVal, ok := dst[key]; ok {
23 srcMap, srcMapOk := mapify(srcVal)
24 dstMap, dstMapOk := mapify(dstVal)
25 if srcMapOk && dstMapOk {
26 srcVal = merge(dstMap, srcMap, depth+1)
27 }
28 }
29 dst[key] = srcVal
30 }
31 return dst
32}
33
34func mapify(i interface{}) (map[string]interface{}, bool) {
35 value := reflect.ValueOf(i)

Callers 1

MergeFunction · 0.85

Calls 1

mapifyFunction · 0.85

Tested by

no test coverage detected