Skip to content

Commit

Permalink
Add comment for using copy slice
Browse files Browse the repository at this point in the history
  • Loading branch information
yongxiu committed Nov 16, 2021
1 parent d5f7500 commit 67b0ee3
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ func paths(path []string, diff map[string]interface{}) [][]string {
for key, m := range diff {
nested, ok := m.(map[string]interface{})
if !ok {
// We have to use a copy of path, because otherwise the slice we append to
// allPaths would be overwritten in another iteration.
tmp := make([]string, len(path))
copy(tmp, path)
allPaths = append(allPaths, append(tmp, key))
Expand Down

0 comments on commit 67b0ee3

Please sign in to comment.