Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mapstr/mapstr.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func cloneMap(dst, src M) {
dst[k] = d
cloneMap(d, v)
case map[string]interface{}:
d := make(map[string]interface{}, len(v))
d := make(M, len(v))
dst[k] = d
cloneMap(d, v)
case []M:
Expand All @@ -181,9 +181,9 @@ func cloneMap(dst, src M) {
}
dst[k] = a
case []map[string]interface{}:
a := make([]map[string]interface{}, 0, len(v))
a := make([]M, 0, len(v))
for _, m := range v {
d := make(map[string]interface{}, len(m))
d := make(M, len(m))
cloneMap(d, m)
a = append(a, d)
}
Expand Down
4 changes: 4 additions & 0 deletions mapstr/mapstr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ func TestClone(t *testing.T) {
"c32": 2,
},
"c4": []M{{"c41": 1}},
"c5": map[string]interface{}{"c51": 1},
"c6": []map[string]interface{}{{"c61": 1}},
}

// Clone the original mapstr and then increment every value in it. Ensures the test will fail if
Expand All @@ -366,6 +368,8 @@ func TestClone(t *testing.T) {
"c32": 2,
},
"c4": []M{{"c41": 1}},
"c5": M{"c51": 1},
"c6": []M{{"c61": 1}},
},
cloned,
)
Expand Down
Loading