optimize: change err == xx to errors.Is(err, xx) (#3991)

This commit is contained in:
mongobaba
2024-03-09 20:49:16 +08:00
committed by GitHub
parent e9e55125a9
commit 459d3025c5
5 changed files with 8 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package iox
import (
"bufio"
"errors"
"io"
"strings"
)
@@ -30,7 +31,7 @@ func (scanner *TextLineScanner) Scan() bool {
line, err := scanner.reader.ReadString('\n')
scanner.line = strings.TrimRight(line, "\n")
if err == io.EOF {
if errors.Is(err, io.EOF) {
scanner.hasNext = false
return true
} else if err != nil {

View File

@@ -122,7 +122,7 @@ func formatError(err error) string {
}
switch {
case err == io.EOF:
case errors.Is(err, io.EOF):
return "eof"
case errors.Is(err, context.DeadlineExceeded):
return "context deadline"