diff --git a/shadirconcurrent/main.go b/shadirconcurrent/main.go index 0240845..e673806 100644 --- a/shadirconcurrent/main.go +++ b/shadirconcurrent/main.go @@ -29,8 +29,7 @@ func main() { for i := 0; i < 100; i++ { go func() { - for { - path := <-chan_path + for path := range chan_path { if h, err := sha256File(path); err != nil { wg.Done() log.Print("Error "+path, err) @@ -42,14 +41,14 @@ func main() { } go func() { - for { - fmt.Println(<-chan_hash) + for h := range chan_hash { + fmt.Println(h) wg.Done() } }() err := filepath.Walk(os.Args[1], func(path string, info os.FileInfo, err error) error { - if err != nil && !info.IsDir() { + if err == nil && !info.IsDir() { wg.Add(1) chan_path <- path }