thread.go
func WaitFunc(interval, timeout time.Duration, f func() bool) bool {
	after := time.After(timeout)
	for {
		select {
		case <-time.After(interval):
			if f() {
				return true
			}
		case <-after:
			return false
		}
	}

	return false
}
func WaitFunc(interval, timeout time.Duration, f func() bool) bool {
	after := time.After(timeout)
	for {
		select {
		case <-time.After(interval):
			if f() {
				return true
			}
		case <-after:
			return false
		}
	}

	return false
}
// WaitFunc waits until specified function returns true.