chore: make fmt.Errorf use %w to wrap error instead of %v (#20350)

This commit is contained in:
Hoa Nguyen
2024-05-12 08:11:25 +00:00
committed by GitHub
parent 6853ba0468
commit 22aa95ccbd
20 changed files with 42 additions and 37 deletions
+3 -3
View File
@@ -935,18 +935,18 @@ func copyFile(src, dest string) (*os.File, error) {
func copyFilesInDir(src, dest string) error {
err := os.MkdirAll(dest, 0o750)
if err != nil {
return fmt.Errorf("mkdirs: %s", err)
return fmt.Errorf("mkdirs: %w", err)
}
fs, err := os.ReadDir(src)
if err != nil {
return fmt.Errorf("read dir: %s", err)
return fmt.Errorf("read dir: %w", err)
}
for _, f := range fs {
if f.IsDir() {
continue
}
if _, err := copyFile(filepath.Join(src, f.Name()), filepath.Join(dest, f.Name())); err != nil {
return fmt.Errorf("copy file: %q: %s", f.Name(), err)
return fmt.Errorf("copy file: %q: %w", f.Name(), err)
}
}
return nil