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

@@ -1,6 +1,7 @@
package generator
import (
"errors"
"fmt"
"io/fs"
"os"
@@ -86,7 +87,7 @@ func findPbFile(current string, src string, grpc bool) (string, error) {
}
return nil
})
if err == os.ErrExist {
if errors.Is(err, os.ErrExist) {
return filepath.Dir(filepath.Join(current, ret)), nil
}
return "", err

View File

@@ -115,7 +115,7 @@ func split(content string) ([]string, error) {
for {
r, _, err := reader.ReadRune()
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
if buffer.Len() > 0 {
list = append(list, buffer.String())
}