MCPcopy Create free account
hub / github.com/google/go-cloud / NewDecoder

Function NewDecoder

runtimevar/runtimevar.go:430–435  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

428// and GobDecode, which can be passed to this function to create Decoders for
429// JSON and gob values.
430func 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.
438func (d *Decoder) Decode(ctx context.Context, b []byte) (any, error) {

Callers 12

Example_jsonDecoderFunction · 0.92
ExampleDecryptDecodeFunction · 0.92
TestNewBytesFunction · 0.92
TestNewFromEnvFunction · 0.92
testJSONFunction · 0.92
testInvalidJSONFunction · 0.92
testUpdateWithErrorsFunction · 0.92
runtimevar.goFile · 0.85
DecoderByNameFunction · 0.85
maybeDecryptFunction · 0.85
TestDecoderFunction · 0.85
TestDecryptDecoderFunction · 0.85

Calls

no outgoing calls

Tested by 6

Example_jsonDecoderFunction · 0.74
ExampleDecryptDecodeFunction · 0.74
TestNewBytesFunction · 0.74
TestNewFromEnvFunction · 0.74
TestDecoderFunction · 0.68
TestDecryptDecoderFunction · 0.68