From 9eceffdf12dc4497ee162c005d5e14bb509797b9 Mon Sep 17 00:00:00 2001 From: Jabar Asadi Date: Wed, 10 May 2023 21:44:14 +0000 Subject: [PATCH] strings: correct NewReader documentation The provided description for `NewReader` says that the underlying string is read-only. but the following example shows that this is not the case.
rd := strings.NewReader("this is a text") rd.Reset("new text") <--- underlying string gets updated here Change-Id: I95c7099c2e63670c84307d4317b702bf13a4025a GitHub-Last-Rev: a16a60b0f1e25d19e05e664c5b41ca57c4fcd9b2 GitHub-Pull-Request: golang/go#60074 Reviewed-on: https://go-review.googlesource.com/c/go/+/493817 Run-TryBot: Ian Lance Taylor Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- src/strings/reader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strings/reader.go b/src/strings/reader.go index 6f069a62cad..04f31a1e8f1 100644 --- a/src/strings/reader.go +++ b/src/strings/reader.go @@ -156,5 +156,5 @@ func (r *Reader) WriteTo(w io.Writer) (n int64, err error) { func (r *Reader) Reset(s string) { *r = Reader{s, 0, -1} } // NewReader returns a new Reader reading from s. -// It is similar to bytes.NewBufferString but more efficient and read-only. +// It is similar to bytes.NewBufferString but more efficient and non-writable. func NewReader(s string) *Reader { return &Reader{s, 0, -1} }