You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
388 B
19 lines
388 B
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package tstime
|
|
|
|
import (
|
|
"math/rand/v2"
|
|
"time"
|
|
)
|
|
|
|
// RandomDurationBetween returns a random duration in range [min,max).
|
|
// If panics if max < min.
|
|
func RandomDurationBetween(min, max time.Duration) time.Duration {
|
|
diff := max - min
|
|
if diff == 0 {
|
|
return min
|
|
}
|
|
return min + rand.N(max-min)
|
|
}
|
|
|