Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 859 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 859 Bytes

Safe

Go Reference Go Report Card codecov

Purpose

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

Usage

Example:

package main

import (
    "fmt"

    "github.com/akramarenkov/safe"
)

func main() {
    sum, err := safe.SumInt[int8](3, 124)
    if err != nil {
        panic(err)
    }

    fmt.Println(sum)

    _, err = safe.SumInt[int8](3, 125)
    if err == nil {
        panic("expected overflow")
    }
    // Output: 127
}