golib/gfile/file_read.go

27 lines
404 B
Go
Raw Normal View History

2023-09-20 07:24:59 +08:00
//
// file_read.go
// Copyright (C) 2023 tiglog <me@tiglog.com>
//
// Distributed under terms of the MIT license.
//
package gfile
import (
"bufio"
"os"
)
// fd, _ := os.Open(filePath)
// defer fd.Close()
// fs := gfile.ReadFile(fd)
//
// for fs.Scan() {
// fmt.Println(fs.Text())
// }
func ReadFile(fd *os.File) *bufio.Scanner {
fs := bufio.NewScanner(fd)
fs.Split(bufio.ScanLines)
return fs
}