This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
modikai-dtool/utils/input_utils.go
2023-08-03 15:25:17 +08:00

33 lines
443 B
Go

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)
}