diff --git a/lib/godoc/search.txt b/lib/godoc/search.txt index 46f7ae478e0..90266292c49 100644 --- a/lib/godoc/search.txt +++ b/lib/godoc/search.txt @@ -1,4 +1,5 @@ -QUERY = {Query} +QUERY +{Query} {.section Accurate} {.or} diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index 7d40000d557..861c2fa7604 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -746,8 +746,9 @@ func infoLineFmt(w io.Writer, x interface{}, format string) { line = index.(*Index).Snippet(line).Line } else { // no line information available because - // we don't have an index - // TODO(gri) Fix this for remote search + // we don't have an index - this should + // never happen; be conservative and don't + // crash line = 0 } } @@ -1392,10 +1393,15 @@ type Query struct { } +type Result struct { + Result []byte +} + + type IndexServer struct{} -func (s *IndexServer) Lookup(query *Query, result *SearchResult) os.Error { - *result = lookup(query.Query) +func (s *IndexServer) Lookup(query *Query, result *Result) os.Error { + result.Result = applyTemplate(searchText, "searchText", lookup(query.Query)) return nil } diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go index 189f45c3cf5..f90316dc457 100644 --- a/src/cmd/godoc/main.go +++ b/src/cmd/godoc/main.go @@ -158,7 +158,7 @@ func loggingHandler(h http.Handler) http.Handler { } -func remoteLookup(query string) (result *SearchResult, err os.Error) { +func remoteLookup(query string) (result *Result, err os.Error) { var client *rpc.Client if *serverAddr != "" { // try server only @@ -178,7 +178,7 @@ func remoteLookup(query string) (result *SearchResult, err os.Error) { } } - result = new(SearchResult) + result = new(Result) err = client.Call("IndexServer.Lookup", &Query{query}, result) if err != nil { return nil, err @@ -281,9 +281,7 @@ func main() { if err != nil { log.Exitf("remoteLookup: %s", err) } - if err := searchText.Execute(result, os.Stdout); err != nil { - log.Exitf("searchText.Execute: %s", err) - } + os.Stdout.Write(result.Result) } return }