From b684e6945199beb4ececde6e62841104e16afd0d Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Wed, 1 Feb 2017 16:59:14 -0600 Subject: [PATCH] Use slices a bit more nicely --- goes.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/goes.go b/goes.go index 94b3fe4..cc7a9d3 100644 --- a/goes.go +++ b/goes.go @@ -145,7 +145,7 @@ func (c *Client) BulkSend(documents []Document) (*Response, error) { // len(documents) * 2 : action + optional_sources // + 1 : room for the trailing \n - bulkData := make([][]byte, len(documents)*2+1) + bulkData := make([][]byte, 0, len(documents)*2+1) i := 0 for _, doc := range documents { @@ -161,7 +161,7 @@ func (c *Client) BulkSend(documents []Document) (*Response, error) { return &Response{}, err } - bulkData[i] = action + bulkData = append(bulkData, action) i++ if doc.Fields != nil { @@ -187,13 +187,13 @@ func (c *Client) BulkSend(documents []Document) (*Response, error) { return &Response{}, err } - bulkData[i] = sources + bulkData = append(bulkData, sources) i++ } } // forces an extra trailing \n absolutely necessary for elasticsearch - bulkData[len(bulkData)-1] = []byte(nil) + bulkData = append(bulkData, []byte(nil)) r := Request{ Method: "POST", @@ -445,7 +445,7 @@ func (c *Client) DeleteMapping(typeName string, indexes []string) (*Response, er func (c *Client) modifyAlias(action string, alias string, indexes []string) (*Response, error) { command := map[string]interface{}{ - "actions": make([]map[string]interface{}, 1), + "actions": make([]map[string]interface{}, 0, 1), } for _, index := range indexes {