Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce DecodeStreamer for Client.Do
This enables a client to stream values out of the HTTP response. It does so by providing a result that implements DecodeStreamer with something like the following. Error handling has been omitted for clarity. // DecodeStream decodes and processes each record of a JSON array func (streamingDecoder) DecodeStream(r io.Reader) error { dec := json.NewDecoder(r) tok, _ := dec.Token() // want: json.Delim('[') for dec.More() { _ = dec.Decode(&record) // do something with record } tok, _ = dec.Token() // want: json.Delim(']') _, err = dec.Token() // want: io.EOF return nil }
- Loading branch information