]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] bufio: discourage use of ReadLine
authorRuss Cox <rsc@golang.org>
Fri, 21 Sep 2012 19:54:27 +0000 (05:54 +1000)
committerRuss Cox <rsc@golang.org>
Fri, 21 Sep 2012 19:54:27 +0000 (05:54 +1000)
««« backport 9e2011d9ed4b
bufio: discourage use of ReadLine

Too many people use it without reading what it does.
Those people want ReadBytes or ReadString.

Fixes #3906.

R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/6442087

»»»

src/pkg/bufio/bufio.go

index b44d0e7d167893c9f813f99ce736adf9fa34131c..0e284825bd05532e68c3cf7ed536721564cdd1c6 100644 (file)
@@ -272,6 +272,9 @@ func (b *Reader) ReadSlice(delim byte) (line []byte, err error) {
        panic("not reached")
 }
 
+// ReadLine is a low-level line-reading primitive. Most callers should use
+// ReadBytes('\n') or ReadString('\n') instead.
+//
 // ReadLine tries to return a single line, not including the end-of-line bytes.
 // If the line was too long for the buffer then isPrefix is set and the
 // beginning of the line is returned. The rest of the line will be returned