]> Cypherpunks repositories - gostls13.git/commitdiff
strings: correct NewReader documentation
authorJabar Asadi <jasadi@d2iq.com>
Wed, 10 May 2023 21:44:14 +0000 (21:44 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 12 May 2023 17:40:51 +0000 (17:40 +0000)
The provided description for `NewReader` says that the underlying string is read-only. but the following example shows that this is not the case.
<br />

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 <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

src/strings/reader.go

index 6f069a62cad82a6f82b9ca472dfe343f0bbf38cb..04f31a1e8f1211c11ffc15ba5c581073eb41f5b9 100644 (file)
@@ -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} }