Add post-Merge fixtures and refactor #6

Merged
roysc merged 13 commits from new-fixtures into main 2024-07-08 06:35:30 +00:00
Showing only changes of commit 292c71b471 - Show all commits

View File

@ -2,6 +2,7 @@ package chains
import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
@ -70,22 +71,16 @@ func copyDir(src, dest string) error {
return err
}
srcDir, err := os.Open(src)
if err != nil {
return err
}
defer srcDir.Close()
fileInfos, err := srcDir.Readdir(-1)
entries, err := os.ReadDir(src)
if err != nil {
return err
}
for _, fileInfo := range fileInfos {
srcPath := filepath.Join(src, fileInfo.Name())
destPath := filepath.Join(dest, fileInfo.Name())
for _, entry := range entries {
srcPath := filepath.Join(src, entry.Name())
destPath := filepath.Join(dest, entry.Name())
if fileInfo.IsDir() {
if entry.IsDir() {
if err := copyDir(srcPath, destPath); err != nil {
return err
}
@ -112,8 +107,5 @@ func copyFile(src, dest string) error {
defer destFile.Close()
_, err = io.Copy(destFile, srcFile)
if err != nil {
return err
}
return nil
return err
}