-
-
Notifications
You must be signed in to change notification settings - Fork 176
Closed
Description
Related to #362
When unmarshaling a struct with an embedded pointer to an aliased primitive, the resulting struct omits the the pointer field leaving it nil
.
The original struct is correctly serialized. For example, in the test below, the AliasedPrimitive field has a value of 7.
func TestIssue372(t *testing.T) {
type AliasedPrimitive int
type Combiner struct {
SomeField int
*AliasedPrimitive
}
aliasedPrimitive := AliasedPrimitive(7)
originalCombiner := Combiner{AliasedPrimitive: &aliasedPrimitive}
b, err := json.Marshal(originalCombiner)
assertErr(t, err)
newCombiner := Combiner{}
err = json.Unmarshal(b, &newCombiner)
assertErr(t, err)
assertEq(t, "TestEmbeddedPrimitiveAlias", *originalCombiner.AliasedPrimitive, *newCombiner.AliasedPrimitive)
}
panics due to newCombiner.AliasedPrimitive
being nil
.
Metadata
Metadata
Assignees
Labels
No labels