NewDecoder returns a Decoder that uses fn to decode a slice of bytes into an object of type obj. This package provides some common Decode functions, including JSONDecode and GobDecode, which can be passed to this function to create Decoders for JSON and gob values.
(obj any, fn Decode)
| 428 | // and GobDecode, which can be passed to this function to create Decoders for |
| 429 | // JSON and gob values. |
| 430 | func NewDecoder(obj any, fn Decode) *Decoder { |
| 431 | return &Decoder{ |
| 432 | typ: reflect.TypeOf(obj), |
| 433 | fn: fn, |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | // Decode decodes b into a new instance of the target type. |
| 438 | func (d *Decoder) Decode(ctx context.Context, b []byte) (any, error) { |
no outgoing calls