util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package util provides utility functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNegativeValue indicates that a negative value was provided where it is not allowed.
	ErrNegativeValue = errors.New("negative value provided")

	// ErrOverflow indicates that a value exceeds the maximum limit for the target type.
	ErrOverflow = errors.New("value exceeds maximum limit for target type")
)

Functions

func SafeInt32

func SafeInt32[T ~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64](value T) (int32, error)

SafeInt32 converts any integer type to int32, returning an error if it would overflow.

func SafeInt64

func SafeInt64[T ~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64](value T) (int64, error)

SafeInt64 converts any integer type to int64, returning an error if it would overflow.

func SafeUint32

func SafeUint32[T ~int | ~int32 | ~int64 | ~uint | ~uint32 | ~uint64](value T) (uint32, error)

SafeUint32 converts any integer type to uint32, returning an error if it would overflow.

Types

This section is empty.

Jump to

Keyboard shortcuts

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