diff
diff copied to clipboard
Patching a nil *int?
Howdy!
What am I missing here: I am unable to patch my "blank" struct property.
The last assertion fails with reflect: call of reflect.Value.Type on zero Value
.
type PatchStruct struct {
Variable *int `json:"Variable"`
}
func TestPatch(t *testing.T) {
changes := []diff.Change{
{
Type: "update",
Path: []string{"Variable"},
From: nil,
To: 4,
},
}
var patchMe PatchStruct
d, err := diff.NewDiffer(diff.ConvertCompatibleTypes())
assert.NoError(t, err)
result := d.Patch(changes, &patchMe)
assert.False(t, result.HasErrors())
}