type ByteReader(interface)
ByteReader is the interface that wraps the ReadByte method.
ReadByte reads and returns the next byte from the input or
any error encountered. If ReadByte returns an error, no input
byte was consumed, and the returned byte value is undefined.
ReadByte provides an efficient interface for byte-at-time
processing. A Reader that does not implement ByteReader
can be wrapped using bufio.NewReader to add this method.
(T) ReadByte() (byte, error)ByteScanner(interface)
bufio.(*Reader)
bufio.ReadWriter
bytes.(*Buffer)
bytes.(*Reader)
compress/flate.Reader(interface)
strings.(*Reader)
func encoding/binary.ReadUvarint(r ByteReader) (uint64, error)
func encoding/binary.ReadVarint(r ByteReader) (int64, error)
type ByteScanner(interface)
ByteScanner is the interface that adds the UnreadByte method to the
basic ReadByte method.
UnreadByte causes the next call to ReadByte to return the same byte
as the previous call to ReadByte.
It may be an error to call UnreadByte twice without an intervening
call to ReadByte.
(T) ReadByte() (byte, error)
(T) UnreadByte() error
bufio.(*Reader)
bufio.ReadWriter
bytes.(*Buffer)
bytes.(*Reader)
strings.(*Reader)
T : ByteReader
type LimitedReader(struct)
A LimitedReader reads from R but limits the amount of
data returned to just N bytes. Each call to Read
updates N to reflect the new amount remaining.
Read returns EOF when N <= 0 or when the underlying R returns EOF.
Nint64RReader
(*T) Read(p []byte) (n int, err error)
*T : Reader
type ReaderAt(interface)
ReaderAt is the interface that wraps the basic ReadAt method.
ReadAt reads len(p) bytes into p starting at offset off in the
underlying input source. It returns the number of bytes
read (0 <= n <= len(p)) and any error encountered.
When ReadAt returns n < len(p), it returns a non-nil error
explaining why more bytes were not returned. In this respect,
ReadAt is stricter than Read.
Even if ReadAt returns n < len(p), it may use all of p as scratch
space during the call. If some data is available but not len(p) bytes,
ReadAt blocks until either all the data is available or an error occurs.
In this respect ReadAt is different from Read.
If the n = len(p) bytes returned by ReadAt are at the end of the
input source, ReadAt may return either err == EOF or err == nil.
If ReadAt is reading from an input source with a seek offset,
ReadAt should not affect nor be affected by the underlying
seek offset.
Clients of ReadAt can execute parallel ReadAt calls on the
same input source.
Implementations must not retain p.
(T) ReadAt(p []byte, off int64) (n int, err error)
*SectionReader
bytes.(*Reader)
mime/multipart.File(interface)
os.(*File)
strings.(*Reader)
func NewSectionReader(r ReaderAt, off int64, n int64) *SectionReader
type ReaderFrom(interface)
ReaderFrom is the interface that wraps the ReadFrom method.
ReadFrom reads data from r until EOF or error.
The return value n is the number of bytes read.
Any error except io.EOF encountered during the read is also returned.
The Copy function uses ReaderFrom if available.
(T) ReadFrom(r Reader) (n int64, err error)
bufio.ReadWriter
bufio.(*Writer)
bytes.(*Buffer)
net.(*TCPConn)
net/http/internal.FlushAfterChunkWriter
os.(*File)
type RuneScanner(interface)
RuneScanner is the interface that adds the UnreadRune method to the
basic ReadRune method.
UnreadRune causes the next call to ReadRune to return the same rune
as the previous call to ReadRune.
It may be an error to call UnreadRune twice without an intervening
call to ReadRune.
(T) ReadRune() (r rune, size int, err error)
(T) UnreadRune() error
bufio.(*Reader)
bufio.ReadWriter
bytes.(*Buffer)
bytes.(*Reader)
fmt.ScanState(interface)
strings.(*Reader)
T : RuneReader
type Seeker(interface)
Seeker is the interface that wraps the basic Seek method.
Seek sets the offset for the next Read or Write to offset,
interpreted according to whence:
SeekStart means relative to the start of the file,
SeekCurrent means relative to the current offset, and
SeekEnd means relative to the end.
Seek returns the new offset relative to the start of the
file and an error, if any.
Seeking to an offset before the start of the file is an error.
Seeking to any positive offset is legal, but the behavior of subsequent
I/O operations on the underlying object is implementation-dependent.
(T) Seek(offset int64, whence int) (int64, error)ReadSeeker(interface)ReadWriteSeeker(interface)
*SectionReaderWriteSeeker(interface)
bytes.(*Reader)
internal/poll.(*FD)
mime/multipart.File(interface)
net/http.File(interface)
os.(*File)
strings.(*Reader)
vendor/golang.org/x/text/unicode/norm.(*Iter)
type WriterAt(interface)
WriterAt is the interface that wraps the basic WriteAt method.
WriteAt writes len(p) bytes from p to the underlying data stream
at offset off. It returns the number of bytes written from p (0 <= n <= len(p))
and any error encountered that caused the write to stop early.
WriteAt must return a non-nil error if it returns n < len(p).
If WriteAt is writing to a destination with a seek offset,
WriteAt should not affect nor be affected by the underlying
seek offset.
Clients of WriteAt can execute parallel WriteAt calls on the same
destination if the ranges do not overlap.
Implementations must not retain p.
(T) WriteAt(p []byte, off int64) (n int, err error)
os.(*File)
type WriterTo(interface)
WriterTo is the interface that wraps the WriteTo method.
WriteTo writes data to w until there's no more data to write or
when an error occurs. The return value n is the number of bytes
written. Any error encountered during the write is also returned.
The Copy function uses WriterTo if available.
(T) WriteTo(w Writer) (n int64, err error)
bufio.(*Reader)
bufio.ReadWriter
bytes.(*Buffer)
bytes.(*Reader)
net.(*Buffers)
strings.(*Reader)
func Copy(dst Writer, src Reader) (written int64, err error)
Copy copies from src to dst until either EOF is reached
on src or an error occurs. It returns the number of bytes
copied and the first error encountered while copying, if any.
A successful Copy returns err == nil, not err == EOF.
Because Copy is defined to read from src until EOF, it does
not treat an EOF from Read as an error to be reported.
If src implements the WriterTo interface,
the copy is implemented by calling src.WriteTo(dst).
Otherwise, if dst implements the ReaderFrom interface,
the copy is implemented by calling dst.ReadFrom(src).
func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error)
CopyBuffer is identical to Copy except that it stages through the
provided buffer (if one is required) rather than allocating a
temporary one. If buf is nil, one is allocated; otherwise if it has
zero length, CopyBuffer panics.
If either src implements WriterTo or dst implements ReaderFrom,
buf will not be used to perform the copy.
func CopyN(dst Writer, src Reader, n int64) (written int64, err error)
CopyN copies n bytes (or until an error) from src to dst.
It returns the number of bytes copied and the earliest
error encountered while copying.
On return, written == n if and only if err == nil.
If dst implements the ReaderFrom interface,
the copy is implemented using it.
var EOFerror
EOF is the error returned by Read when no more input is available.
Functions should return EOF only to signal a graceful end of input.
If the EOF occurs unexpectedly in a structured data stream,
the appropriate error is either ErrUnexpectedEOF or some other error
giving more detail.
var ErrClosedPipeerror
ErrClosedPipe is the error used for read or write operations on a closed pipe.
var ErrNoProgresserror
ErrNoProgress is returned by some clients of an io.Reader when
many calls to Read have failed to return any data or error,
usually the sign of a broken io.Reader implementation.
var ErrShortBuffererror
ErrShortBuffer means that a read required a longer buffer than was provided.
var ErrShortWriteerror
ErrShortWrite means that a write accepted fewer bytes than requested
but failed to return an explicit error.
var ErrUnexpectedEOFerror
ErrUnexpectedEOF means that EOF was encountered in the
middle of reading a fixed-size block or data structure.
func LimitReader(r Reader, n int64) Reader
LimitReader returns a Reader that reads from r
but stops with EOF after n bytes.
The underlying implementation is a *LimitedReader.
func MultiReader(readers ...Reader) Reader
MultiReader returns a Reader that's the logical concatenation of
the provided input readers. They're read sequentially. Once all
inputs have returned EOF, Read will return EOF. If any of the readers
return a non-nil, non-EOF error, Read will return that error.
func MultiWriter(writers ...Writer) Writer
MultiWriter creates a writer that duplicates its writes to all the
provided writers, similar to the Unix tee(1) command.
Each write is written to each listed writer, one at a time.
If a listed writer returns an error, that overall write operation
stops and returns the error; it does not continue down the list.
func Pipe() (*PipeReader, *PipeWriter)
Pipe creates a synchronous in-memory pipe.
It can be used to connect code expecting an io.Reader
with code expecting an io.Writer.
Reads and Writes on the pipe are matched one to one
except when multiple Reads are needed to consume a single Write.
That is, each Write to the PipeWriter blocks until it has satisfied
one or more Reads from the PipeReader that fully consume
the written data.
The data is copied directly from the Write to the corresponding
Read (or Reads); there is no internal buffering.
It is safe to call Read and Write in parallel with each other or with Close.
Parallel calls to Read and parallel calls to Write are also safe:
the individual calls will be gated sequentially.
func ReadAtLeast(r Reader, buf []byte, min int) (n int, err error)
ReadAtLeast reads from r into buf until it has read at least min bytes.
It returns the number of bytes copied and an error if fewer bytes were read.
The error is EOF only if no bytes were read.
If an EOF happens after reading fewer than min bytes,
ReadAtLeast returns ErrUnexpectedEOF.
If min is greater than the length of buf, ReadAtLeast returns ErrShortBuffer.
On return, n >= min if and only if err == nil.
If r returns an error having read at least min bytes, the error is dropped.
func ReadFull(r Reader, buf []byte) (n int, err error)
ReadFull reads exactly len(buf) bytes from r into buf.
It returns the number of bytes copied and an error if fewer bytes were read.
The error is EOF only if no bytes were read.
If an EOF happens after reading some but not all the bytes,
ReadFull returns ErrUnexpectedEOF.
On return, n == len(buf) if and only if err == nil.
If r returns an error having read at least len(buf) bytes, the error is dropped.
const SeekCurrent = 1 // seek relative to the current offset
Seek whence values.
const SeekEnd = 2 // seek relative to the end
Seek whence values.
const SeekStart = 0 // seek relative to the origin of the file
Seek whence values.
func TeeReader(r Reader, w Writer) Reader
TeeReader returns a Reader that writes to w what it reads from r.
All reads from r performed through it are matched with
corresponding writes to w. There is no internal buffering -
the write must complete before the read completes.
Any error encountered while writing is reported as a read error.
func WriteString(w Writer, s string) (n int, err error)
WriteString writes the contents of the string s to w, which accepts a slice of bytes.
If w implements StringWriter, its WriteString method is invoked directly.
Otherwise, w.Write is called exactly once.
The pages are generated with Goldsv0.1.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project and developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.