shithub: furgit

ref: ab174c473618dd3743881cf44e02c2db4d1ecd5f
dir: /internal/intconv/u64_i.go/

View raw version
package intconv

import (
	"fmt"
	"math"
)

// Uint64ToInt converts v to int, returning an error if it overflows.
func Uint64ToInt(v uint64) (int, error) {
	if v > uint64(math.MaxInt) {
		return 0, fmt.Errorf("intconv: uint64 %d overflows int", v)
	}

	return int(v), nil
}