We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go语言中文件按行读取的方法:
func readsLine(path string, fn func(string)) { f, err := os.Open(path) if err != nil { log.Fatal(err) } defer f.Close() buf := bufio.NewReader(f) for { line, err := buf.ReadString('\n') if err != nil && io.EOF == err { break } fn(line) } }
其中path为要打开文件的路径,fn为操作读取到数据的方法,func(string)为操作方法的类型
path
fn
func(string)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Go语言中文件按行读取的方法:
其中
path
为要打开文件的路径,fn
为操作读取到数据的方法,func(string)
为操作方法的类型The text was updated successfully, but these errors were encountered: