fix the bug in cloning slices (#129)

* test: add test cases for cloning slices.

* fix: fix the bug in cloning slices.
This commit is contained in:
Wang Huan authored and GitHub committed 2023-09-06 16:16:25 +08:00
1 parent de104ebeb6
commit 07fc453b74
2 files changed
+2 -1

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ func (c *cloner) cloneArray(v reflect.Value) reflect.Value {
for i := 0; i < v.Len(); i++ {
val := c.clone(v.Index(i))
if val.IsValid() {
if !val.IsValid() {
continue
}
+1
View File
@@ -337,6 +337,7 @@ func TestDeepClone(t *testing.T) {
Nil: nil,
// unexported: "can't be cloned",
},
[]interface{}{1, &Struct{Str: "test"}, Struct{Str: "test2"}},
}
for i, item := range cases {