use native error instead of github.com/pkg/errors

Signed-off-by: wangyysde <net_use@bzhy.com>
This commit is contained in:
wangyysde 2021-06-23 22:14:18 +08:00
parent 7b24c7e4a7
commit e2e1c94f06

View File

@ -21,12 +21,12 @@ package main
import (
"bufio"
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
"regexp"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@ -48,7 +48,7 @@ func checkAllProviders(e2eFile string) error {
fileInput, err := ioutil.ReadFile(e2eFile)
if err != nil {
return errors.Wrapf(err, "Failed to read file %s", e2eFile)
return fmt.Errorf("Failed to read file %s: %w", e2eFile, err)
}
scanner := bufio.NewScanner(bytes.NewReader(fileInput))
scanner.Split(bufio.ScanLines)
@ -57,7 +57,7 @@ func checkAllProviders(e2eFile string) error {
line := scanner.Text()
if regStartConformance.MatchString(line) {
if inConformanceCode {
return errors.Errorf("Missed the end of previous conformance test. There might be a bug in this script.")
return errors.New("Missed the end of previous conformance test. There might be a bug in this script.")
}
inConformanceCode = true
}
@ -73,10 +73,10 @@ func checkAllProviders(e2eFile string) error {
}
}
if inConformanceCode {
return errors.Errorf("Missed the end of previous conformance test. There might be a bug in this script.")
return errors.New("Missed the end of previous conformance test. There might be a bug in this script.")
}
if checkFailed {
return errors.Errorf("We need to fix the above errors.")
return errors.New("We need to fix the above errors.")
}
return nil
}
@ -86,7 +86,7 @@ func processFile(e2ePath string) error {
files, err := ioutil.ReadDir(e2ePath)
if err != nil {
return errors.Wrapf(err, "Failed to read dir %s", e2ePath)
return fmt.Errorf("Failed to read dir %s: %w", e2ePath, err)
}
for _, file := range files {
if file.IsDir() {
@ -113,7 +113,7 @@ func processDir(e2ePath string) error {
// Search sub directories if exist
files, err := ioutil.ReadDir(e2ePath)
if err != nil {
return errors.Wrapf(err, "Failed to read dir %s", e2ePath)
return fmt.Errorf("Failed to read dir %s: %w", e2ePath, err)
}
for _, file := range files {
if !file.IsDir() {