diff --git a/analyze/dir.go b/analyze/dir.go index 556242c19..5f50d8afa 100644 --- a/analyze/dir.go +++ b/analyze/dir.go @@ -1,6 +1,7 @@ package analyze import ( + "io/ioutil" "log" "os" "path/filepath" @@ -84,10 +85,9 @@ func (a *ParallelAnalyzer) processDir(path string) *File { err error mutex sync.Mutex totalSize int64 - info os.FileInfo ) - files, err := os.ReadDir(path) + files, err := ioutil.ReadDir(path) if err != nil { log.Print(err.Error()) } @@ -121,17 +121,17 @@ func (a *ParallelAnalyzer) processDir(path string) *File { a.wait.Done() }() } else { - info, _ = f.Info() file = &File{ Name: f.Name(), - Flag: getFlag(info), - Size: info.Size(), + Flag: getFlag(f), + Size: f.Size(), ItemCount: 1, Parent: &dir, } - setPlatformSpecificAttrs(file, info) - totalSize += info.Size() + setPlatformSpecificAttrs(file, f) + + totalSize += f.Size() mutex.Lock() dir.Files = append(dir.Files, file) diff --git a/go.mod b/go.mod index 0ab1bee52..67228c9fe 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/dundee/gdu/v4 -go 1.16 +go 1.15 require ( github.com/fatih/color v1.10.0 diff --git a/internal/testdir/test_dir.go b/internal/testdir/test_dir.go index fd99a7be0..2809a9782 100644 --- a/internal/testdir/test_dir.go +++ b/internal/testdir/test_dir.go @@ -1,14 +1,15 @@ package testdir import ( + "io/ioutil" "os" ) // CreateTestDir creates test dir structure func CreateTestDir() func() { os.MkdirAll("test_dir/nested/subnested", os.ModePerm) - os.WriteFile("test_dir/nested/subnested/file", []byte("hello"), 0644) - os.WriteFile("test_dir/nested/file2", []byte("go"), 0644) + ioutil.WriteFile("test_dir/nested/subnested/file", []byte("hello"), 0644) + ioutil.WriteFile("test_dir/nested/file2", []byte("go"), 0644) return func() { err := os.RemoveAll("test_dir") if err != nil {