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

Function sizeof

sizeof.go:9–29  ·  view source on GitHub ↗
(a interface{})

Source from the content-addressed store, hash-verified

7}
8
9func sizeof(a interface{}) int32 {
10 switch v := a.(type) {
11 case int8:
12 return 1
13 case int16:
14 return 2
15 case int32:
16 return 4
17 case int64:
18 return 8
19 case string:
20 return sizeofString(v)
21 case bool:
22 return 1
23 case []byte:
24 return sizeofBytes(v)
25 case sizable:
26 return v.size()
27 }
28 panic(fmt.Sprintf("unsupported type: %T", a))
29}
30
31func sizeofInt16(_ int16) int32 {
32 return 2

Callers 1

TestProtocolFunction · 0.85

Calls 3

sizeofStringFunction · 0.85
sizeofBytesFunction · 0.85
sizeMethod · 0.65

Tested by 1

TestProtocolFunction · 0.68