You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I frequently see code where an http.Response.Body is decoded with json.Decoder, under the presumption that json.Decoder performs memory saving streaming. In fact, it is not more efficient and it is arguably incorrect for http.Responses where only one value should be present.
Here is the current docstring:
A Decoder reads and decodes JSON values from an input stream.
Here is a proposed docstring:
A Decoder reads and decodes JSON values from an input stream. For a stream that should only have a single JSON value, use Unmarshal.
The text was updated successfully, but these errors were encountered:
I think the better long term fix here would be #36225; Unmarshal is not a particularly better option right now. The decoder buffering an entire value can be surprising, but I don't think it's a behavior that we want to document and teach people. I especially don't want people to memorize that Unmarshal is supposedly faster than Decoder.Decode for a single value, because that might not be true in the future.
I frequently see code where an http.Response.Body is decoded with json.Decoder, under the presumption that json.Decoder performs memory saving streaming. In fact, it is not more efficient and it is arguably incorrect for http.Responses where only one value should be present.
Here is the current docstring:
Here is a proposed docstring:
The text was updated successfully, but these errors were encountered: