diff --git a/chains/chaindata.go b/chains/chaindata.go index 592cf4f..e83cb65 100644 --- a/chains/chaindata.go +++ b/chains/chaindata.go @@ -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 }