-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
Reading lines from a file is too cumbersome in Go. People are often drawn to bufio.Reader.ReadLine because of its name, but it has a weird signature, returning (line []byte, isPrefix bool, err error), and requires a lot of work. ReadSlice and ReadString require a delimiter byte, which is almost always the obvious and unsightly '\n', and also can return both a line and an EOF: http://play.golang.org/p/LSl2Aketpg This bug is about designing a nicer API for bufio to do the common task of looping over lines from an io.Reader. Things to think about: -- functional or not, like my earlier https://golang.org/cl/6870052/ proposal and filepath.Walk. -- if an iterator: return either a line OR an error, but never both? -- auto-strip line endings before giving it to the caller? -- CRLF vs LF -- treat the final line without line endings the same as a line with a line ending? -- skip, fail early, or truncate lines that are longer than the bufio Reader size? -- string or []byte? (copy or not?) etc.
Reactions are currently unavailable