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