MCPcopy Create free account
hub / github.com/segmentio/encoding / encodeFuncOf

Function encodeFuncOf

thrift/encode.go:67–104  ·  view source on GitHub ↗
(t reflect.Type, seen encodeFuncCache)

Source from the content-addressed store, hash-verified

65type encodeFuncCache map[reflect.Type]encodeFunc
66
67func encodeFuncOf(t reflect.Type, seen encodeFuncCache) encodeFunc {
68 f := seen[t]
69 if f != nil {
70 return f
71 }
72 switch t.Kind() {
73 case reflect.Bool:
74 f = encodeBool
75 case reflect.Int8:
76 f = encodeInt8
77 case reflect.Int16:
78 f = encodeInt16
79 case reflect.Int32:
80 f = encodeInt32
81 case reflect.Int64, reflect.Int:
82 f = encodeInt64
83 case reflect.Float32, reflect.Float64:
84 f = encodeFloat64
85 case reflect.String:
86 f = encodeString
87 case reflect.Slice:
88 if t.Elem().Kind() == reflect.Uint8 {
89 f = encodeBytes
90 } else {
91 f = encodeFuncSliceOf(t, seen)
92 }
93 case reflect.Map:
94 f = encodeFuncMapOf(t, seen)
95 case reflect.Struct:
96 f = encodeFuncStructOf(t, seen)
97 case reflect.Ptr:
98 f = encodeFuncPtrOf(t, seen)
99 default:
100 panic("type cannot be encoded in thrift: " + t.String())
101 }
102 seen[t] = f
103 return f
104}
105
106func encodeBool(w Writer, v reflect.Value, _ flags) error {
107 return w.WriteBool(v.Bool())

Callers 6

EncodeMethod · 0.85
encodeFuncSliceOfFunction · 0.85
encodeFuncMapOfFunction · 0.85
encodeFuncMapAsSetOfFunction · 0.85
encodeFuncStructFieldOfFunction · 0.85
encodeFuncPtrOfFunction · 0.85

Calls 7

encodeFuncSliceOfFunction · 0.85
encodeFuncMapOfFunction · 0.85
encodeFuncStructOfFunction · 0.85
encodeFuncPtrOfFunction · 0.85
KindMethod · 0.65
ElemMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…