This example from the json.Unmarshal docs (slightly modified for simplicity to use
var animals Animal
err := json.Unmarshal(jsonBlob, &animals)
var animals *Animal
err := json.Unmarshal(jsonBlob, animals)
json: Unmarshal(nil *main.Animal)
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.
// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal.
// (The argument to Unmarshal must be a non-nil pointer.)
It seems the docs could do with some clarification as the quote above and the comment below from the
Unmarshal source seem to contradict each other.
If the pointer is nil, Unmarshal allocates a new value for it to point to.