MCPcopy
hub / github.com/tinylib/msgp / writeExt

Function writeExt

msgp/json_bytes.go:341–368  ·  view source on GitHub ↗
(w jsWriter, r RawExtension, scratch []byte)

Source from the content-addressed store, hash-verified

339}
340
341func writeExt(w jsWriter, r RawExtension, scratch []byte) ([]byte, error) {
342 _, err := w.WriteString(`{"type":`)
343 if err != nil {
344 return scratch, err
345 }
346 scratch = strconv.AppendInt(scratch[0:0], int64(r.Type), 10)
347 _, err = w.Write(scratch)
348 if err != nil {
349 return scratch, err
350 }
351 _, err = w.WriteString(`,"data":"`)
352 if err != nil {
353 return scratch, err
354 }
355 l := base64.StdEncoding.EncodedLen(len(r.Data))
356 if cap(scratch) >= l {
357 scratch = scratch[0:l]
358 } else {
359 scratch = make([]byte, l)
360 }
361 base64.StdEncoding.Encode(scratch, r.Data)
362 _, err = w.Write(scratch)
363 if err != nil {
364 return scratch, err
365 }
366 _, err = w.WriteString(`"}`)
367 return scratch, err
368}

Callers 1

rwExtensionBytesFunction · 0.85

Calls 2

WriteStringMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…