small improve

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2022-03-27 01:37:21 +03:00
parent 35ab6ae84e
commit 03410c4ab1
2 changed files with 39 additions and 0 deletions

View File

@@ -13,3 +13,8 @@ func Random(d time.Duration) time.Duration {
v := rng.Float64() * float64(d.Nanoseconds())
return time.Duration(v)
}
func RandomInterval(min, max time.Duration) time.Duration {
var rng rand.Rand
return time.Duration(rng.Int63n(max.Nanoseconds()-min.Nanoseconds())+min.Nanoseconds()) * time.Nanosecond
}