Skip to content

Commit

Permalink
fixed #12: CanSet for struct elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
name5566 committed Jan 25, 2016
1 parent ae511b1 commit bb3d734
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func deepCopy(dst, src reflect.Value) {
}
case reflect.Struct:
for i := 0; i < src.NumField(); i++ {
deepCopy(dst.Field(i), src.Field(i))
value := src.Field(i)
if value.CanSet() {
deepCopy(dst.Field(i), value)
}
}
default:
dst.Set(src)
Expand Down

0 comments on commit bb3d734

Please sign in to comment.