24 lines
341 B
Go
24 lines
341 B
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"bufio"
|
||
|
"os"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func Readfile(filename string, out chan<- string) error {
|
||
|
file, err := os.Open(filename)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer file.Close()
|
||
|
|
||
|
scanner := bufio.NewScanner(file)
|
||
|
for scanner.Scan() {
|
||
|
line := strings.TrimSpace(scanner.Text())
|
||
|
out <- line
|
||
|
}
|
||
|
|
||
|
return scanner.Err()
|
||
|
}
|