| 129 | } |
| 130 | |
| 131 | func processFile(path string, work chan<- string) error { |
| 132 | fmt.Println("processing", path) |
| 133 | |
| 134 | fd, err := os.Open(path) |
| 135 | if err != nil { |
| 136 | fmt.Println("error in processing file ::", err) |
| 137 | return err |
| 138 | } |
| 139 | defer fd.Close() |
| 140 | |
| 141 | scanner := bufio.NewScanner(fd) |
| 142 | for scanner.Scan() { |
| 143 | work <- scanner.Text() |
| 144 | } |
| 145 | |
| 146 | if err := scanner.Err(); err != nil { |
| 147 | fmt.Println("error in reading file ::", err) |
| 148 | return err |
| 149 | } |
| 150 | |
| 151 | return nil |
| 152 | } |
| 153 | |
| 154 | func doWork(id int, c *y.Closer, work <-chan string, outDir string) { |
| 155 | defer c.Done() |