1 // Copyright 2017 Frank Schroeder. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 // make this a var to overwrite it in a test
13 var is32Bit = ^uint(0) == math.MaxUint32
15 // intRangeCheck checks if the value fits into the int type and
16 // panics if it does not.
17 func intRangeCheck(key string, v int64) int {
18 if is32Bit && (v < math.MinInt32 || v > math.MaxInt32) {
19 panic(fmt.Sprintf("Value %d for key %s out of range", v, key))
24 // uintRangeCheck checks if the value fits into the uint type and
25 // panics if it does not.
26 func uintRangeCheck(key string, v uint64) uint {
27 if is32Bit && v > math.MaxUint32 {
28 panic(fmt.Sprintf("Value %d for key %s out of range", v, key))