MCPcopy Create free account
hub / github.com/goadesign/goa / Encode

Method Encode

http/encoding.go:315–327  ·  view source on GitHub ↗
(v any)

Source from the content-addressed store, hash-verified

313}
314
315func (e *textEncoder) Encode(v any) (err error) {
316 switch c := v.(type) {
317 case string:
318 _, err = e.w.Write([]byte(c))
319 case *string: // v may be a string pointer when the Response Body is set to the field of a custom response type.
320 _, err = e.w.Write([]byte(*c))
321 case []byte:
322 _, err = e.w.Write(c)
323 default:
324 err = fmt.Errorf("can't encode %T as %s", c, e.ct)
325 }
326 return
327}
328
329func newTextDecoder(r io.Reader, ct string) Decoder {
330 return &textDecoder{r, ct}

Callers

nothing calls this directly

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected