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