MCPcopy
hub / github.com/jackc/pgx / Scan

Method Scan

pgtype/int.go:329–355  ·  view source on GitHub ↗
(src []byte, dst any)

Source from the content-addressed store, hash-verified

327type scanPlanBinaryInt2ToUint8 struct{}
328
329func (scanPlanBinaryInt2ToUint8) Scan(src []byte, dst any) error {
330 if src == nil {
331 return fmt.Errorf("cannot scan NULL into %T", dst)
332 }
333
334 if len(src) != 2 {
335 return fmt.Errorf("invalid length for uint2: %v", len(src))
336 }
337
338 p, ok := (dst).(*uint8)
339 if !ok {
340 return ErrScanTargetTypeChanged
341 }
342
343 n := int16(binary.BigEndian.Uint16(src))
344 if n < 0 {
345 return fmt.Errorf("%d is less than minimum value for uint8", n)
346 }
347
348 if n > math.MaxUint8 {
349 return fmt.Errorf("%d is greater than maximum value for uint8", n)
350 }
351
352 *p = uint8(n)
353
354 return nil
355}
356
357type scanPlanBinaryInt2ToInt16 struct{}
358

Callers

nothing calls this directly

Calls 1

Uint16Method · 0.80

Tested by

no test coverage detected