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 }