Files
scroll/common/utils/utils.go
2022-12-19 14:49:01 +08:00

14 lines
239 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; i < times; i++ {
if run() {
return
}
time.Sleep(time.Millisecond * 500)
}
}