Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectoryInfo ¶
func GetDirInfo ¶
func GetDirInfo(fSys fs.FS) (dirInfo DirectoryInfo, errs []error)
GetDirInfo Traverse each root of the file tree in parallel returning the total file count and total size of all the files.
Example ¶
tmpDir, err := os.MkdirTemp("", "example_test")
check(err)
tmpDir2, err := os.MkdirTemp(tmpDir, "example_test2")
check(err)
test123, err := os.CreateTemp(tmpDir, "test_123")
check(err)
testABC, err := os.CreateTemp(tmpDir2, "test_abc")
check(err)
defer func() {
_ = test123.Close()
_ = testABC.Close()
}()
dirInfo, _ := dirSize.GetDirInfo(os.DirFS("."))
fmt.Printf("%d files size: %1.f\n", dirInfo.FileCount, float64(dirInfo.TotalSize))
Output: 2 files size: 0
Click to show internal directories.
Click to hide internal directories.