Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esutil/bulk_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (item *BulkIndexerItem) marshallMeta() {
}
item.meta.WriteString(`"require_alias":`)
item.meta.Write(strconv.AppendBool(aux, item.RequireAlias))
aux = aux[:0]
_ = aux[:0]
}

if item.DocumentID != "" && item.IfSeqNo != nil && item.IfPrimaryTerm != nil {
Expand Down
4 changes: 2 additions & 2 deletions esutil/bulk_indexer_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package esutil_test
import (
"bytes"
"context"
"io/ioutil"
"io"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -55,7 +55,7 @@ var mockResponseBody = `{
type mockTransp struct{}

func (t *mockTransp) RoundTrip(req *http.Request) (*http.Response, error) {
return &http.Response{Body: ioutil.NopCloser(strings.NewReader(mockResponseBody))}, nil // 1x alloc
return &http.Response{Body: io.NopCloser(strings.NewReader(mockResponseBody))}, nil // 1x alloc
}

func BenchmarkBulkIndexer(b *testing.B) {
Expand Down
6 changes: 3 additions & 3 deletions esutil/bulk_indexer_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,17 @@ func TestBulkIndexer(t *testing.T) {
successFunc := func(ctx context.Context, item BulkIndexerItem, res BulkIndexerResponseItem) {
atomic.AddUint64(&countSuccessful, 1)

buf, err := ioutil.ReadAll(item.Body)
buf, err := io.ReadAll(item.Body)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
successfulItemBodies = append(successfulItemBodies, string(buf))
}
failureFunc := func(ctx context.Context, item BulkIndexerItem, res BulkIndexerResponseItem, err error) {
failureFunc := func(ctx context.Context, item BulkIndexerItem, res BulkIndexerResponseItem, _ error) {
atomic.AddUint64(&countFailed, 1)
failedIDs = append(failedIDs, item.DocumentID)

buf, err := ioutil.ReadAll(item.Body)
buf, err := io.ReadAll(item.Body)
if err != nil {
t.Fatalf("Unexpected error: %s", err)
}
Expand Down
5 changes: 2 additions & 3 deletions esutil/json_reader_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"strings"
"testing"

Expand Down Expand Up @@ -71,7 +70,7 @@ func BenchmarkJSONReader(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
out, _ := ioutil.ReadAll(esutil.NewJSONReader(map[string]string{"foo": "bar"}))
out, _ := io.ReadAll(esutil.NewJSONReader(map[string]string{"foo": "bar"}))
if string(out) != `{"foo":"bar"}`+"\n" {
b.Fatalf("Unexpected output: %q", out)
}
Expand All @@ -95,7 +94,7 @@ func BenchmarkJSONReader(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
out, _ := ioutil.ReadAll(esutil.NewJSONReader(Foo{Bar: "baz"}))
out, _ := io.ReadAll(esutil.NewJSONReader(Foo{Bar: "baz"}))
if string(out) != `{"bar":"BAZ"}`+"\n" {
b.Fatalf("Unexpected output: %q", out)
}
Expand Down
5 changes: 2 additions & 3 deletions esutil/json_reader_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"bytes"
"errors"
"io"
"io/ioutil"
"strings"
"testing"
)
Expand All @@ -49,14 +48,14 @@ func (f Foo) EncodeJSON(w io.Writer) error {

func TestJSONReader(t *testing.T) {
t.Run("Default", func(t *testing.T) {
out, _ := ioutil.ReadAll(NewJSONReader(map[string]string{"foo": "bar"}))
out, _ := io.ReadAll(NewJSONReader(map[string]string{"foo": "bar"}))
if string(out) != `{"foo":"bar"}`+"\n" {
t.Fatalf("Unexpected output: %s", out)
}
})

t.Run("Custom", func(t *testing.T) {
out, _ := ioutil.ReadAll(NewJSONReader(Foo{Bar: "baz"}))
out, _ := io.ReadAll(NewJSONReader(Foo{Bar: "baz"}))
if string(out) != `{"bar":"BAZ"}`+"\n" {
t.Fatalf("Unexpected output: %s", out)
}
Expand Down