ruspa/real_walker.go
2020-03-01 23:09:00 +01:00

28 lines
481 B
Go

package main
import (
"os"
"path/filepath"
)
type RealWalker struct {
path string
report chan int64
}
func (r *RealWalker) walkFunc(path string, info os.FileInfo, err error) error {
switch mode := info.Mode(); {
case mode.IsRegular():
r.report <- info.Size()
}
return nil
}
func (r *RealWalker) Walk() {
filepath.Walk(r.path, r.walkFunc)
}
func NewRealWalker(path string, report chan int64) *RealWalker {
r := &RealWalker{path: path, report: report}
return r
}