ResetWithOptions will reset the decoder and apply the given options for the next stream or DecodeAll operation. Options are applied on top of the existing options. Some options cannot be changed on reset and will return an error.
(r io.Reader, opts ...DOption)
| 238 | // Options are applied on top of the existing options. |
| 239 | // Some options cannot be changed on reset and will return an error. |
| 240 | func (d *Decoder) ResetWithOptions(r io.Reader, opts ...DOption) error { |
| 241 | d.o.resetOpt = true |
| 242 | defer func() { d.o.resetOpt = false }() |
| 243 | for _, o := range opts { |
| 244 | if err := o(&d.o); err != nil { |
| 245 | return err |
| 246 | } |
| 247 | } |
| 248 | return d.Reset(r) |
| 249 | } |
| 250 | |
| 251 | // drainOutput will drain the output until errEndOfStream is sent. |
| 252 | func (d *Decoder) drainOutput() { |