MCPcopy Create free account
hub / github.com/blues/note / resolve

Method resolve

jsonxt/encode.go:866–885  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

864}
865
866func (w *reflectWithString) resolve() error {
867 if w.v.Kind() == reflect.String {
868 w.s = w.v.String()
869 return nil
870 }
871 if tm, ok := w.v.Interface().(encoding.TextMarshaler); ok {
872 buf, err := tm.MarshalText()
873 w.s = string(buf)
874 return err
875 }
876 switch w.v.Kind() {
877 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
878 w.s = strconv.FormatInt(w.v.Int(), 10)
879 return nil
880 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
881 w.s = strconv.FormatUint(w.v.Uint(), 10)
882 return nil
883 }
884 panic("unexpected map key type")
885}
886
887// NOTE: keep in sync with stringBytes below.
888func (e *encodeState) string(s string, escapeHTML bool) {

Callers 1

encodeMethod · 0.80

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected