]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add documentation to reader methods
authorGabriel Aszalos <gabriel.aszalos@gmail.com>
Thu, 21 Sep 2017 10:25:02 +0000 (12:25 +0200)
committerIan Lance Taylor <iant@golang.org>
Thu, 21 Sep 2017 18:57:04 +0000 (18:57 +0000)
Some methods that were used to implement various `io` interfaces in the
Reader were documented, whereas others were not. This change adds
documentation to all the missing methods used to implement these
interfaces.

Change-Id: I2dac6e328542de3cd87e89510651cd6ba74a7b7d
Reviewed-on: https://go-review.googlesource.com/65231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/bytes/reader.go

index 28cfc7a97884a7d448c585f6b6d866fcfe9c914d..08464c2402d74648eb84f620419c6b4a00a0875a 100644 (file)
@@ -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 complements ReadByte in implementing the io.ByteScanner interface.
 func (r *Reader) UnreadByte() error {
        r.prevRune = -1
        if r.i <= 0 {
@@ -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 complements ReadRune in implementing the io.RuneScanner interface.
 func (r *Reader) UnreadRune() error {
        if r.prevRune < 0 {
                return errors.New("bytes.Reader.UnreadRune: previous operation was not ReadRune")