What steps will reproduce the problem?
var s string = "foo"
err := Unmarshal(byte(`null`), &s)
does not change s, but also does not signal an error.
While this does make some sense, it surprised me; I expected either an error or zero
value. Error because `null` is not a string, zero value because that's what the logic is
elsewhere for null:
"To unmarshal JSON into a pointer, Unmarshal first handles the case of the JSON
being the JSON literal null. In that case, Unmarshal sets the pointer to nil. Otherwise,
Unmarshal unmarshals the JSON into the value pointed at by the pointer. If the pointer
is nil, Unmarshal allocates a new value for it to point to."
which means that unmarshaling `null` into a pointer actually changes it, and
unmarshaling `null` into a non-pointer doesn't.
I feel like the docs need an extra paragraph that talks about null.
The text was updated successfully, but these errors were encountered: