blob: a968f076f847a0d41bde429fe2d1e8139719c7a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
package utils
import (
"bufio"
"fmt"
"io"
"os"
"strings"
)
func RetrieveLines(pool chan string, filename string) {
cnt := 0
f, err := os.Open(filename)
if err != nil {
panic(err)
}
fmt.Println("reading file ...")
reader := bufio.NewReader(f)
for {
s, err := reader.ReadString('\n')
if err == io.EOF {
break
}
s = strings.Trim(s, "\n")
pool <- s
cnt++
if cnt%10 == 0 {
fmt.Println(cnt)
}
}
close(pool)
}
|