MCPcopy
hub / github.com/segmentio/kafka-go / encodeFuncOf

Function encodeFuncOf

protocol/encode.go:376–405  ·  view source on GitHub ↗
(typ reflect.Type, version int16, flexible bool, tag structTag)

Source from the content-addressed store, hash-verified

374)
375
376func encodeFuncOf(typ reflect.Type, version int16, flexible bool, tag structTag) encodeFunc {
377 if reflect.PtrTo(typ).Implements(writerTo) {
378 return writerEncodeFuncOf(typ)
379 }
380 switch typ.Kind() {
381 case reflect.Bool:
382 return (*encoder).encodeBool
383 case reflect.Int8:
384 return (*encoder).encodeInt8
385 case reflect.Int16:
386 return (*encoder).encodeInt16
387 case reflect.Int32:
388 return (*encoder).encodeInt32
389 case reflect.Int64:
390 return (*encoder).encodeInt64
391 case reflect.Float64:
392 return (*encoder).encodeFloat64
393 case reflect.String:
394 return stringEncodeFuncOf(flexible, tag)
395 case reflect.Struct:
396 return structEncodeFuncOf(typ, version, flexible)
397 case reflect.Slice:
398 if typ.Elem().Kind() == reflect.Uint8 { // []byte
399 return bytesEncodeFuncOf(flexible, tag)
400 }
401 return arrayEncodeFuncOf(typ, version, flexible, tag)
402 default:
403 panic("unsupported type: " + typ.String())
404 }
405}
406
407func stringEncodeFuncOf(flexible bool, tag structTag) encodeFunc {
408 switch {

Callers 4

makeTypesFunction · 0.85
structEncodeFuncOfFunction · 0.85
arrayEncodeFuncOfFunction · 0.85
MarshalFunction · 0.85

Calls 6

writerEncodeFuncOfFunction · 0.85
stringEncodeFuncOfFunction · 0.85
structEncodeFuncOfFunction · 0.85
bytesEncodeFuncOfFunction · 0.85
arrayEncodeFuncOfFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected