Merge pull request #2893 from Fish-pro/clean/errlint
Use errors.Is to check for a specific error
This commit is contained in:
commit
b94500a27d
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue