1
0
mirror of https://github.com/golang/go synced 2024-11-20 05:04:43 -07:00

add a standard interface that wraps ReadByte, io.ReadByter

R=rsc
CC=golang-dev
https://golang.org/cl/181163
This commit is contained in:
Rob Pike 2010-01-07 13:29:43 +11:00
parent 4cde1a903b
commit fce5d60b38

View File

@ -150,6 +150,14 @@ type WriterAt interface {
WriteAt(p []byte, off int64) (n int, err os.Error) WriteAt(p []byte, off int64) (n int, err os.Error)
} }
// ReadByter is the interface that wraps the ReadByte method.
//
// ReadByte reads and returns the next byte from the input.
// If no byte is available, err will be set.
type ReadByter interface {
ReadByte() (c byte, err os.Error)
}
// WriteString writes the contents of the string s to w, which accepts an array of bytes. // WriteString writes the contents of the string s to w, which accepts an array of bytes.
func WriteString(w Writer, s string) (n int, err os.Error) { func WriteString(w Writer, s string) (n int, err os.Error) {
return w.Write(strings.Bytes(s)) return w.Write(strings.Bytes(s))