From 87e741c38f3851828e99b76d059cbffdbd9cc3ab Mon Sep 17 00:00:00 2001 From: Brad Garcia Date: Fri, 20 Jun 2014 06:24:12 -0400 Subject: [PATCH] godoc: add Corpus.ReadIndexFrom, which will be useful for creating a split indexing/frontend godoc instance. R=sameer, sameer CC=golang-codereviews https://golang.org/cl/78850043 --- godoc/index.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/godoc/index.go b/godoc/index.go index aeea29f969..417c386bd1 100644 --- a/godoc/index.go +++ b/godoc/index.go @@ -1430,8 +1430,13 @@ func (c *Corpus) readIndex(filenames string) error { defer f.Close() files = append(files, f) } + return c.ReadIndexFrom(io.MultiReader(files...)) +} + +// ReadIndexFrom sets the current index from the serialized version found in r. +func (c *Corpus) ReadIndexFrom(r io.Reader) error { x := new(Index) - if _, err := x.ReadFrom(io.MultiReader(files...)); err != nil { + if _, err := x.ReadFrom(r); err != nil { return err } if !x.CompatibleWith(c) {