Skip to content

Commit

Permalink
Fix linter errors #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tdancheva committed May 29, 2023
1 parent f47b905 commit 8565da8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions libbeat/reader/readfile/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package readfile

import (
"bytes"
"errors"
"fmt"
"io"

Expand Down Expand Up @@ -93,7 +94,7 @@ func (r *LineReader) Next() (b []byte, n int, err error) {
// read next 'potential' line from input buffer/reader
err := r.advance()
if err != nil {
if (err == io.EOF) && r.collectOnEOF {
if errors.Is(err, io.EOF) && r.collectOnEOF {
// Found EOF and collectOnEOF is true
// -> decode input sequence into outBuffer
// let's take whole buffer len without len(nl) if it ends with it
Expand Down Expand Up @@ -183,7 +184,7 @@ func (r *LineReader) advance() error {
// Try to read more bytes into buffer
n, err := r.reader.Read(r.tempBuffer)

if (err == io.EOF) && n > 0 {
if errors.Is(err, io.EOF) && n > 0 {
// Continue processing the returned bytes. The next call will yield EOF with 0 bytes.
err = nil
}
Expand Down
5 changes: 3 additions & 2 deletions libbeat/reader/readfile/line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package readfile
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestReaderEncodings(t *testing.T) {
bytes, sz, err := reader.Next()
if sz > 0 {
offset := len(bytes)
if offset > 0 && (!test.collectOnEOF || !(err == io.EOF) || test.withEOL) {
if offset > 0 && (!test.collectOnEOF || !errors.Is(err, io.EOF) || test.withEOL) {
offset -= len(nl)
}
readLines = append(readLines, string(bytes[:offset]))
Expand Down Expand Up @@ -434,7 +435,7 @@ func TestMaxBytesLimit(t *testing.T) {
for i := 0; ; i++ {
b, n, err := reader.Next()
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
readLen += n
break
} else {
Expand Down

0 comments on commit 8565da8

Please sign in to comment.