Categorygithub.com/akramarenkov/safe
repositorypackage
0.16.0
Repository: https://github.com/akramarenkov/safe.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# README

Safe

Go Reference Go Report Card Coverage Status

Purpose

Library that allows you to detect and avoid overflows in operations with integer numbers

Usage

Example:

package main

import (
    "fmt"

    "github.com/akramarenkov/safe"
)

func main() {
    sum, err := safe.Add[int8](124, 3)
    fmt.Println(err)
    fmt.Println(sum)

    sum, err = safe.Add[int8](125, 3)
    fmt.Println(err)
    fmt.Println(sum)
    // Output:
    // <nil>
    // 127
    // integer overflow
    // 0
}