This repository has been archived on 2025-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
miniauthold/vendor/github.com/magiconair/properties/rangecheck.go
kekskurse 19dab2268e
Some checks failed
ci/woodpecker/push/test Pipeline failed
ci/woodpecker/push/playwright unknown status
ci/woodpecker/push/deplyoment unknown status
chore: login methode return user
2025-05-25 20:41:22 +02:00

31 lines
843 B
Go

// Copyright 2013-2022 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package properties
import (
"fmt"
"math"
)
// make this a var to overwrite it in a test
var is32Bit = ^uint(0) == math.MaxUint32
// intRangeCheck checks if the value fits into the int type and
// panics if it does not.
func intRangeCheck(key string, v int64) int {
if is32Bit && (v < math.MinInt32 || v > math.MaxInt32) {
panic(fmt.Sprintf("Value %d for key %s out of range", v, key))
}
return int(v)
}
// uintRangeCheck checks if the value fits into the uint type and
// panics if it does not.
func uintRangeCheck(key string, v uint64) uint {
if is32Bit && v > math.MaxUint32 {
panic(fmt.Sprintf("Value %d for key %s out of range", v, key))
}
return uint(v)
}