mirror of
https://github.com/golang/go
synced 2024-11-20 04:04:41 -07:00
bytes: add documentation to reader methods
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>
This commit is contained in:
parent
fdecab6ef0
commit
dd5a86f18c
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user