Rejig ordering of timeout
diff --git a/util.go b/util.go
index 92ca910..6f62944 100644
--- a/util.go
+++ b/util.go
@@ -14,6 +14,11 @@
// Force a 1s sleep
time.Sleep(1 * time.Second)
+ // If a timeout is set, and that's been exceeded, shut it down
+ if timeout >= 0 && time.Now().Second()-start >= timeout {
+ return errors.New("A timeout occurred")
+ }
+
// Execute the function
satisfied, err := predicate()
if err != nil {
@@ -22,11 +27,6 @@
if satisfied {
return nil
}
-
- // If a timeout is set, and that's been exceeded, shut it down
- if timeout > 0 && time.Now().Second()-start >= timeout {
- return errors.New("A timeout occurred")
- }
}
}