sizing

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package sizing provides safe size arithmetic and conversions to prevent overflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUint64

func AddUint64(a, b uint64) (uint64, bool)

AddUint64 adds two uint64 values, returning (result, false) on overflow.

func ReadAllWithLimit

func ReadAllWithLimit(r io.Reader, maxSize uint64, overflowErr error) ([]byte, error)

ReadAllWithLimit reads up to maxSize bytes from r. Returns overflowErr if more than maxSize bytes are available.

func ToInt

func ToInt(size uint64, overflowErr error) (int, error)

ToInt converts a uint64 to int, returning overflowErr if it doesn't fit.

func ToInt64

func ToInt64(size uint64, overflowErr error) (int64, error)

ToInt64 converts a uint64 to int64, returning overflowErr if it doesn't fit.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL