From 01efc9a3c54f1b8fc772084e3311b6e1ccdfabec Mon Sep 17 00:00:00 2001 From: "Norman B. Lancaster" Date: Thu, 1 Oct 2020 19:14:04 +0000 Subject: strings: complete documentation of strings.Reader There is no documentation on a number of methods of the strings.Reader struct, so this change adds documentation referring to the relevant io.* interfaces implemented. This is consistent with pre-existing documentation in this struct. Fixes #40381 Change-Id: I3dec65ecafca5b79d85d30a676d297e5ee9ab47e GitHub-Last-Rev: f42429946a2b90b9fbfbd1ea5943f0c50e0439b5 GitHub-Pull-Request: golang/go#40654 Reviewed-on: https://go-review.googlesource.com/c/go/+/247523 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Robert Griesemer Trust: Ian Lance Taylor --- src/strings/reader.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/strings') diff --git a/src/strings/reader.go b/src/strings/reader.go index eb2fa1164c..e03f3c5cf8 100644 --- a/src/strings/reader.go +++ b/src/strings/reader.go @@ -35,6 +35,7 @@ func (r *Reader) Len() int { // to any other method. func (r *Reader) Size() int64 { return int64(len(r.s)) } +// Read implements the io.Reader interface. func (r *Reader) Read(b []byte) (n int, err error) { if r.i >= int64(len(r.s)) { return 0, io.EOF @@ -45,6 +46,7 @@ func (r *Reader) Read(b []byte) (n int, err error) { return } +// ReadAt implements the io.ReaderAt interface. func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) { // cannot modify state - see io.ReaderAt if off < 0 { @@ -60,6 +62,7 @@ func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) { return } +// ReadByte implements the io.ByteReader interface. func (r *Reader) ReadByte() (byte, error) { r.prevRune = -1 if r.i >= int64(len(r.s)) { @@ -70,6 +73,7 @@ func (r *Reader) ReadByte() (byte, error) { return b, nil } +// UnreadByte implements the io.ByteScanner interface. func (r *Reader) UnreadByte() error { if r.i <= 0 { return errors.New("strings.Reader.UnreadByte: at beginning of string") @@ -79,6 +83,7 @@ func (r *Reader) UnreadByte() error { return nil } +// ReadRune implements the io.RuneReader interface. func (r *Reader) ReadRune() (ch rune, size int, err error) { if r.i >= int64(len(r.s)) { r.prevRune = -1 @@ -94,6 +99,7 @@ func (r *Reader) ReadRune() (ch rune, size int, err error) { return } +// UnreadRune implements the io.RuneScanner interface. func (r *Reader) UnreadRune() error { if r.i <= 0 { return errors.New("strings.Reader.UnreadRune: at beginning of string") -- cgit v1.2.1