cmd/godoc: start RunIndexer synchronously when index is present

Until the index is read completely, search requests will serve
an "indexing in progress" message. We make this synchronous
to allow the index to be read completely before starting to serve
requests.

Fixes golang/go#24965

Change-Id: I6b094374a9c5cc923f0582107dde2b652e64fd96
Reviewed-on: https://go-review.googlesource.com/c/148998
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/cmd/godoc/appinit.go b/cmd/godoc/appinit.go
index 6318bb7..1f276d8 100644
--- a/cmd/godoc/appinit.go
+++ b/cmd/godoc/appinit.go
@@ -84,7 +84,11 @@
 	}
 	corpus.IndexDirectory = indexDirectoryDefault
 	corpus.InitVersionInfo()
-	go corpus.RunIndexer()
+	if indexFilenames != "" {
+		corpus.RunIndexer()
+	} else {
+		go corpus.RunIndexer()
+	}
 
 	pres = godoc.NewPresentation(corpus)
 	pres.TabWidth = 8