MCPcopy Index your code
hub / github.com/segmentio/encoding / encodeTextMarshaler

Method encodeTextMarshaler

json/encode.go:887–907  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer, t reflect.Type, pointer bool)

Source from the content-addressed store, hash-verified

885}
886
887func (e encoder) encodeTextMarshaler(b []byte, p unsafe.Pointer, t reflect.Type, pointer bool) ([]byte, error) {
888 v := reflect.NewAt(t, p)
889
890 if !pointer {
891 v = v.Elem()
892 }
893
894 switch v.Kind() {
895 case reflect.Ptr, reflect.Interface:
896 if v.IsNil() {
897 return append(b, `null`...), nil
898 }
899 }
900
901 s, err := v.Interface().(encoding.TextMarshaler).MarshalText()
902 if err != nil {
903 return b, err
904 }
905
906 return e.encodeString(b, unsafe.Pointer(&s))
907}
908
909func appendCompactEscapeHTML(dst []byte, src []byte) []byte {
910 start := 0

Callers 1

Calls 4

encodeStringMethod · 0.95
ElemMethod · 0.65
KindMethod · 0.65
MarshalTextMethod · 0.45

Tested by

no test coverage detected