Skip to content
New issue

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

bufio: Missed last line when read file by bufio.NewScanner(f).Scan() #21063

Closed
AJIOB opened this issue Jul 18, 2017 · 1 comment
Closed

bufio: Missed last line when read file by bufio.NewScanner(f).Scan() #21063

AJIOB opened this issue Jul 18, 2017 · 1 comment

Comments

@AJIOB
Copy link

AJIOB commented Jul 18, 2017

What version of Go are you using (go version)?

go version go1.8.3 windows/amd64

What operating system and processor architecture are you using (go env)?

Windows 10 Pro x64 version 1703 (OS build 15063.483)

What did you do?

Code: https://play.golang.org/p/PlxIOWk271
It is a simple example dup3 from Kernighan Go book. I'm passing arguments one.txt and two.txt (files from archieve One version.zip) and gets such output:
2 Hello
Run command: go run main.go one.txt two.txt

But when I'm addnig simple '\n' escape sequence symbol (Version two.zip) in file one.txt, I'm getting such output:
2 Hello
2 me

Why didi I loose last line of file one.txt by reading by Scan() and Text() functions?

@mvdan
Copy link
Member

mvdan commented Jul 18, 2017

This is very likely a bug in your program. If you're confident it isn't, please open an issue with a small program that reproduces the issue on play.golang.org.

Also note how the source code even notes how errors aren't checked.

For questions about Go, see https://golang.org/wiki/Questions.

@mvdan mvdan closed this as completed Jul 18, 2017
@mikioh mikioh changed the title Missed last line when read file by bufio.NewScanner(f).Scan() bufio: Missed last line when read file by bufio.NewScanner(f).Scan() Jul 21, 2017
@golang golang locked and limited conversation to collaborators Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants