This commit is contained in:
Alexander Pivkin
2026-01-04 14:56:29 +03:00
parent 747b022b9c
commit 9f41cbe454
3 changed files with 155 additions and 7 deletions
BIN
View File
Binary file not shown.
+22 -7
View File
@@ -5,8 +5,12 @@ import (
"fmt"
"os"
"path/filepath"
"time"
)
var verbos = flag.Bool("v",false,"show verbose")
func main() {
flag.Parse()
roots := flag.Args()
@@ -23,13 +27,25 @@ func main() {
close(fileSizes)
}()
var nfiles,nbytes int64
for size := range fileSizes {
nfiles++
nbytes += size
}
printDU(nfiles,nbytes)
var tick <- chan time.Time
if *verbos{
tick = time.Tick(500 * time.Millisecond)
}
var nfiles,nbytes int64
loop:
for {
select {
case size,ok := <- fileSizes:
if !ok {
break loop
}
nfiles++
nbytes += size
case <- tick:
printDU(nfiles,nbytes)
}
}
}
func printDU(nfiles, nbytes int64) {
@@ -50,7 +66,6 @@ func WalkDir(dir string, fileSizes chan <- int64) {
func dirents(dir string) []os.DirEntry{
entries, err := os.ReadDir(dir)
fmt.Println(entries)
if err != nil {
fmt.Fprintf(os.Stderr,"du1: %v\n",err)
return nil