Skip to content

Commit c53ff28

Browse files
bufio: document ReadFrom/WriteTo calls to underlying methods
In general use of these magic methods must be documented so that users understand what will happen. Fixes #23289 Change-Id: Ic46915eee1d3b7e57d8d1886834ddfb2e8e66e62 Reviewed-on: https://go-review.googlesource.com/103238 Reviewed-by: Rob Pike <[email protected]>
1 parent 2f14fc9 commit c53ff28

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bufio/bufio.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ func (b *Reader) ReadString(delim byte) (string, error) {
462462

463463
// WriteTo implements io.WriterTo.
464464
// This may make multiple calls to the Read method of the underlying Reader.
465+
// If the underlying reader supports the WriteTo method,
466+
// this calls the underlying WriteTo without buffering.
465467
func (b *Reader) WriteTo(w io.Writer) (n int64, err error) {
466468
n, err = b.writeBuf(w)
467469
if err != nil {
@@ -684,7 +686,9 @@ func (b *Writer) WriteString(s string) (int, error) {
684686
return nn, nil
685687
}
686688

687-
// ReadFrom implements io.ReaderFrom.
689+
// ReadFrom implements io.ReaderFrom. If the underlying writer
690+
// supports the ReadFrom method, and b has no buffered data yet,
691+
// this calls the underlying ReadFrom without buffering.
688692
func (b *Writer) ReadFrom(r io.Reader) (n int64, err error) {
689693
if b.Buffered() == 0 {
690694
if w, ok := b.wr.(io.ReaderFrom); ok {

0 commit comments

Comments
 (0)