mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
fix issue of overflow in grand.D
This commit is contained in:
@ -100,7 +100,7 @@ func S(n int, symbols ...bool) string {
|
||||
|
||||
// D returns a random time.Duration between min and max: [min, max].
|
||||
func D(min, max time.Duration) time.Duration {
|
||||
multiple := 1
|
||||
multiple := int64(1)
|
||||
if min != 0 {
|
||||
for min%10 == 0 {
|
||||
multiple *= 10
|
||||
@ -108,7 +108,7 @@ func D(min, max time.Duration) time.Duration {
|
||||
max /= 10
|
||||
}
|
||||
}
|
||||
n := N(int(min), int(max))
|
||||
n := int64(N(int(min), int(max)))
|
||||
return time.Duration(n * multiple)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user