Merge pull request #2893 from Fish-pro/clean/errlint

Use errors.Is to check for a specific error
This commit is contained in:
karmada-bot 2022-12-01 12:17:13 +08:00 committed by GitHub
commit b94500a27d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package utils
import (
"archive/tar"
"compress/gzip"
"errors"
"fmt"
"io"
"net/http"
@ -84,7 +85,7 @@ func DeCompress(file, targetPath string) error {
tr := tar.NewReader(gr)
for {
header, err := tr.Next()
if err == io.EOF {
if errors.Is(err, io.EOF) {
break
}
if err != nil {
@ -116,7 +117,7 @@ func DeCompress(file, targetPath string) error {
func ioCopyN(outFile *os.File, tr *tar.Reader) error {
for {
if _, err := io.CopyN(outFile, tr, 1024); err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
break
}
return err

View File

@ -3,6 +3,7 @@ package genericresource
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@ -176,7 +177,7 @@ func (v *StreamVisitor) Visit(fn VisitorFunc) error {
for {
ext := runtime.RawExtension{}
if err := d.Decode(&ext); err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
return nil
}
return fmt.Errorf("error parsing %s: %v", v.Source, err)