fix issue 2391 (#2398)

* v2.3.0

* fix #2391

* fix issue #2391
This commit is contained in:
John Guo
2023-01-16 16:00:18 +08:00
committed by GitHub
parent 6ff4ed84e5
commit 3f6669e2b7
2 changed files with 42 additions and 2 deletions

View File

@ -407,7 +407,7 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in
array[arrayIndex] = doMapConvertForMapOrStructValue(
doMapConvertForMapOrStructValueInput{
IsRoot: false,
Value: rvAttrField.Index(arrayIndex),
Value: rvAttrField.Index(arrayIndex).Interface(),
RecursiveType: in.RecursiveType,
RecursiveOption: in.RecursiveType == recursiveTypeTrue,
Tags: in.Tags,
@ -463,7 +463,7 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in
for i := 0; i < length; i++ {
array[i] = doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{
IsRoot: false,
Value: reflectValue.Index(i),
Value: reflectValue.Index(i).Interface(),
RecursiveType: in.RecursiveType,
RecursiveOption: in.RecursiveType == recursiveTypeTrue,
Tags: in.Tags,

View File

@ -223,3 +223,43 @@ func Test_Issue2381(t *testing.T) {
t.Assert(a1.Flag.String(), a2.Flag.String())
})
}
// https://github.com/gogf/gf/issues/2391
func Test_Issue2391(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
type Inherit struct {
Ids []int
Ids2 []int64
Flag *gjson.Json
Title string
}
type Test1 struct {
Inherit
}
type Test2 struct {
Inherit
}
var (
a1 Test1
a2 Test2
)
a1 = Test1{
Inherit{
Ids: []int{1, 2, 3},
Ids2: []int64{4, 5, 6},
Flag: gjson.New("[\"1\", \"2\"]"),
Title: "测试",
},
}
err := gconv.Scan(a1, &a2)
t.AssertNil(err)
t.Assert(a1.Ids, a2.Ids)
t.Assert(a1.Ids2, a2.Ids2)
t.Assert(a1.Title, a2.Title)
t.Assert(a1.Flag.String(), a2.Flag.String())
})
}