MCPcopy Create free account
hub / github.com/PostHog/duckgres / encodeInt2

Function encodeInt2

server/types.go:321–348  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

319}
320
321func encodeInt2(v interface{}) []byte {
322 buf := make([]byte, 2)
323 var n int16
324 switch val := v.(type) {
325 case int:
326 n = int16(val)
327 case int8:
328 n = int16(val)
329 case int16:
330 n = val
331 case int32:
332 n = int16(val)
333 case int64:
334 n = int16(val)
335 case uint8:
336 n = int16(val)
337 case uint16:
338 n = int16(val)
339 case float32:
340 n = int16(val)
341 case float64:
342 n = int16(val)
343 default:
344 return nil
345 }
346 binary.BigEndian.PutUint16(buf, uint16(n))
347 return buf
348}
349
350func encodeInt4(v interface{}) []byte {
351 buf := make([]byte, 4)

Callers 2

TestEncodeInt2Function · 0.85
encodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEncodeInt2Function · 0.68