-
Notifications
You must be signed in to change notification settings - Fork 18k
bufio: reading lines is too cumbersome #4802
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
Personally I would feel that an iterator would be more convenient when reading lines. The error could be similar to that of io.ReadFull: "The error is EOF only if no bytes were read. If an EOF happens after reading some but not all the bytes, ReadFull returns ErrUnexpectedEOF. On return, n == len(buf) if and only if err == nil." Return ErrUnexpectedEOF (or similar) if the line didn't end with a new line. Only return EOF when no line was read. Possibly return an error for truncated lines, ErrLineTruncated (or similar). Line rog already pointed out: "You almost always want to strip off the final newline" ref: https://golang.org/cl/6870052/#msg8 If a copy should be made or not is a hard choice. Can't tell at this point what my thoughts are. It is always easy to provide a wrapper function to make the copy. The question is, do we want to limit the need of such wrapper functions? |
This issue was closed by revision 55ad7b9. 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: