mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-16 11:37:36 +02:00
2d645434d8
* Externalized common timeout values * Updated go.sum
54 lines
826 B
Go
54 lines
826 B
Go
package core
|
|
|
|
import (
|
|
"math"
|
|
"math/rand"
|
|
"reflect"
|
|
)
|
|
|
|
func IsNil(input interface{}) bool {
|
|
val := reflect.ValueOf(input)
|
|
kind := val.Kind()
|
|
|
|
switch kind {
|
|
case reflect.Ptr,
|
|
reflect.Array,
|
|
reflect.Slice,
|
|
reflect.Map,
|
|
reflect.Func,
|
|
reflect.Interface,
|
|
reflect.Chan:
|
|
return val.IsNil()
|
|
case reflect.Struct,
|
|
reflect.UnsafePointer:
|
|
return false
|
|
case reflect.Invalid:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func NumberBoundaries(input float64) (max float64, min float64) {
|
|
min = input / 2
|
|
max = input * 2
|
|
|
|
return
|
|
}
|
|
|
|
func NumberUpperBoundary(input float64) float64 {
|
|
return input * 2
|
|
}
|
|
|
|
func NumberLowerBoundary(input float64) float64 {
|
|
return input / 2
|
|
}
|
|
|
|
func Random(max float64, min float64) float64 {
|
|
r := rand.Float64()
|
|
i := r * (max - min + 1)
|
|
out := math.Floor(i) + min
|
|
|
|
return out
|
|
}
|