Files
scroll/common/utils/utils.go
2023-02-17 11:37:14 +08:00

14 lines
254 B
Go

package utils
import "time"
// TryTimes try run several times until the function return true.
func TryTimes(times int, run func() bool) {
for i := 0; times == -1 || i < times; i++ {
if run() {
return
}
time.Sleep(time.Millisecond * 500)
}
}