mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-22 08:48:43 +02:00
fix deserialization: reflect: indirection through nil pointer to embedded struct
This commit is contained in:
@@ -53,11 +53,23 @@ func TestDeserializeAnonymousField(t *testing.T) {
|
||||
Anon
|
||||
C int
|
||||
}
|
||||
var s2 struct {
|
||||
*Anon
|
||||
C int
|
||||
}
|
||||
// all, anon := extractFields(reflect.TypeOf(s2))
|
||||
// t.Fatalf("anon %v, all %v", anon, all)
|
||||
err := Deserialize(map[string]any{"a": 1, "b": 2, "c": 3}, &s)
|
||||
ExpectNoError(t, err)
|
||||
ExpectEqual(t, s.A, 1)
|
||||
ExpectEqual(t, s.B, 2)
|
||||
ExpectEqual(t, s.C, 3)
|
||||
|
||||
err = Deserialize(map[string]any{"a": 1, "b": 2, "c": 3}, &s2)
|
||||
ExpectNoError(t, err)
|
||||
ExpectEqual(t, s2.A, 1)
|
||||
ExpectEqual(t, s2.B, 2)
|
||||
ExpectEqual(t, s2.C, 3)
|
||||
}
|
||||
|
||||
func TestStringIntConvert(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user