diff options
Diffstat (limited to 'pkg/query')
| -rw-r--r-- | pkg/query/outputs.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/pkg/query/outputs.go b/pkg/query/outputs.go index a37cded..92331ef 100644 --- a/pkg/query/outputs.go +++ b/pkg/query/outputs.go @@ -139,21 +139,11 @@ func (o JsonOutput) Output(docs []*index.Document) (string, error) { } func (o JsonOutput) OutputTo(w io.Writer, docs []*index.Document) (int, error) { - n := 0 - for _, doc := range docs { - b, err := json.Marshal(doc) - if err != nil { - return n, err - } - - nn, err := w.Write(b) - if err != nil { - return n, err - } - n += nn + b, err := json.Marshal(docs) + if err != nil { + return 0, err } - - return n, nil + return w.Write(b) } func ParseOutputFormat(formatStr string) ([]OutputToken, []string, error) { |
