safecast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package safecast provides bounded conversions for numeric values at protocol boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Int32FromIntClamp

func Int32FromIntClamp(v int) int32

Int32FromIntClamp converts v to int32, clamping to [math.MinInt32, math.MaxInt32]. Use at provider boundaries after validation (e.g. lipapi bounds max_output_tokens) so static analyzers see an explicit bound even when invariants already hold.

func IntFromInt64Clamp

func IntFromInt64Clamp(v int64) int

IntFromInt64Clamp converts v to int, clamping when v does not fit the platform int size. Use for telemetry and usage counters where silent truncation is worse than saturation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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