blob: 59b26a73f0d3fc984c7c1be184ed8c8fed3d6821 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
package intconv
import (
"fmt"
"math"
)
// Uint64ToInt64 converts v to int64, returning an error if it overflows.
func Uint64ToInt64(v uint64) (int64, error) {
if v > math.MaxInt64 {
return 0, fmt.Errorf("intconv: uint64 %d overflows int64", v)
}
return int64(v), nil
}
|