-
Notifications
You must be signed in to change notification settings - Fork 18k
bufio: document that ReadLine ignores missing \n at EOF #3825
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
Labels
Milestone
Comments
The second case is handled correctly; it's the first case that may be a bit surprising. The last line is incomplete (missing LF), but the documentation for ReadLine states: "ReadLine either returns a non-nil line or it returns an error, never both." As a result, if an incomplete line is followed by EOF, ReadLine has to return whatever it managed to find without any error indication. For this and some other reasons, I prefer to use ReadSlice('\n') instead and do my own line ending checks. |
Comment 2 by ikkwong@google.com: Please have a look at this: http://play.golang.org/p/Yb3Alqee25 The there is an extra first line with ReadLine and missing last empty line. |
Your for loop performs the first iteration before ReadLine is called. Here's the corrected version, which works as expected: http://play.golang.org/p/wCL4JX5eWv |
This issue was closed by revision f0d9ccb. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: