cmd/godoc: move poll sleep to top of loop

CL 196979 moved the pollInterval sleep to the bottom of the loop
with the intent of not sleeping before the first readiness check,
but that caused an unintended consequence of the sleep being skipped
when errors happen. Move it back to the top to avoid that problem.

Change-Id: Ia63f09afe47d93df657ca867ceecc4d7df6abccc
Reviewed-on: https://go-review.googlesource.com/c/tools/+/197940
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/cmd/godoc/godoc_test.go b/cmd/godoc/godoc_test.go
index dff079d..0b5c476 100644
--- a/cmd/godoc/godoc_test.go
+++ b/cmd/godoc/godoc_test.go
@@ -126,6 +126,7 @@
 func waitForServer(t *testing.T, ch chan<- error, url, match string, timeout time.Duration, reverse bool) {
 	deadline := time.Now().Add(timeout)
 	for time.Now().Before(deadline) {
+		time.Sleep(pollInterval)
 		if t.Failed() {
 			return
 		}
@@ -144,7 +145,6 @@
 			ch <- nil
 			return
 		}
-		time.Sleep(pollInterval)
 	}
 	ch <- fmt.Errorf("server failed to respond in %v", timeout)
 }