Namespace: go.std.io
v1.0Contents
Summary
Provides a low-level interface to the io package.
Package io provides basic interfaces to I/O primitives.
Its primary job is to wrap existing implementations of such primitives,
such as those in package os, into shared public interfaces that
abstract the functionality, plus some other related primitives.
Because these interfaces and primitives wrap lower-level operations with
various implementations, unless otherwise informed clients should not
assume they are safe for parallel execution.
Index
- *LimitedReader
- *PipeReader
- *PipeWriter
- *SectionReader
- ByteReader
- ByteScanner
- ByteWriter
- Closer
- Copy
- CopyBuffer
- CopyN
- Discard
- EOF
- ErrClosedPipe
- ErrNoProgress
- ErrShortBuffer
- ErrShortWrite
- ErrUnexpectedEOF
- LimitReader
- LimitedReader
- MultiReader
- MultiWriter
- NewSectionReader
- NopCloser
- Pipe
- PipeReader
- PipeWriter
- ReadAll
- ReadAtLeast
- ReadCloser
- ReadFull
- ReadSeekCloser
- ReadSeeker
- ReadWriteCloser
- ReadWriteSeeker
- ReadWriter
- Reader
- ReaderAt
- ReaderFrom
- RuneReader
- RuneScanner
- SectionReader
- SeekCurrent
- SeekEnd
- SeekStart
- Seeker
- StringWriter
- TeeReader
- WriteCloser
- WriteSeeker
- WriteString
- Writer
- WriterAt
- WriterTo
- arrayOfByteReader
- arrayOfByteScanner
- arrayOfByteWriter
- arrayOfCloser
- arrayOfLimitedReader
- arrayOfPipeReader
- arrayOfPipeWriter
- arrayOfReadCloser
- arrayOfReadSeekCloser
- arrayOfReadSeeker
- arrayOfReadWriteCloser
- arrayOfReadWriteSeeker
- arrayOfReadWriter
- arrayOfReader
- arrayOfReaderAt
- arrayOfReaderFrom
- arrayOfRuneReader
- arrayOfRuneScanner
- arrayOfSectionReader
- arrayOfSeeker
- arrayOfStringWriter
- arrayOfWriteCloser
- arrayOfWriteSeeker
- arrayOfWriter
- arrayOfWriterAt
- arrayOfWriterTo
Legend
-
Constant
Variable
Function
Macro
Special form
Type
GoVar
Receiver/Method
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
SeekCurrent
Int v1.0seek relative to the current offset
-
SeekEnd
Int v1.0seek relative to the end
-
SeekStart
Int v1.0seek relative to the origin of the file
Variables
-
Discard
Var v1.0Discard is a Writer on which all Write calls succeed
without doing anything.
-
EOF
Var v1.0EOF is the error returned by Read when no more input is available.
(Read must return EOF itself, not an error wrapping EOF,
because callers will test for EOF using ==.)
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.
-
ErrClosedPipe
Var v1.0ErrClosedPipe is the error used for read or write operations on a closed pipe.
-
ErrNoProgress
Var v1.0ErrNoProgress is returned by some clients of a Reader when
many calls to Read have failed to return any data or error,
usually the sign of a broken Reader implementation.
-
ErrShortBuffer
Var v1.0ErrShortBuffer means that a read required a longer buffer than was provided.
-
ErrShortWrite
Var v1.0ErrShortWrite means that a write accepted fewer bytes than requested
but failed to return an explicit error.
-
ErrUnexpectedEOF
Var v1.0ErrUnexpectedEOF means that EOF was encountered in the
middle of reading a fixed-size block or data structure.
Functions, Macros, and Special Forms
-
Copy
Function v1.0(Copy dst src)
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).
Go input arguments: (dst Writer, src Reader)
Go returns: (written int64, err error)
Joker input arguments: [^Writer dst, ^Reader src]
Joker returns: [^BigInt written, ^Error err] -
CopyBuffer
Function v1.0(CopyBuffer dst src buf)
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.
Go input arguments: (dst Writer, src Reader, buf []byte)
Go returns: (written int64, err error)
Joker input arguments: [^Writer dst, ^Reader src, ^arrayOfByte buf]
Joker returns: [^BigInt written, ^Error err] -
CopyN
Function v1.0(CopyN dst src n)
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.
Go input arguments: (dst Writer, src Reader, n int64)
Go returns: (written int64, err error)
Joker input arguments: [^Writer dst, ^Reader src, ^BigInt n]
Joker returns: [^BigInt written, ^Error err] -
LimitReader
Function v1.0(LimitReader r n)
LimitReader returns a Reader that reads from r
but stops with EOF after n bytes.
The underlying implementation is a *LimitedReader.
Go input arguments: (r Reader, n int64)
Go returns: Reader
Joker input arguments: [^Reader r, ^BigInt n]
Joker returns: ^Reader -
MultiReader
Function v1.0(MultiReader & readers)
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.
Go input arguments: (readers ...Reader)
Go returns: Reader
Joker input arguments: [& ^Reader readers]
Joker returns: ^Reader -
MultiWriter
Function v1.0(MultiWriter & writers)
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.
Go input arguments: (writers ...Writer)
Go returns: Writer
Joker input arguments: [& ^Writer writers]
Joker returns: ^Writer -
NewSectionReader
Function v1.0(NewSectionReader r off n)
NewSectionReader returns a SectionReader that reads from r
starting at offset off and stops with EOF after n bytes.
Go input arguments: (r ReaderAt, off int64, n int64)
Go returns: *SectionReader
Joker input arguments: [^ReaderAt r, ^BigInt off, ^BigInt n]
Joker returns: ^*SectionReader -
NopCloser
Function v1.0(NopCloser r)
NopCloser returns a ReadCloser with a no-op Close method wrapping
the provided Reader r.
If r implements WriterTo, the returned ReadCloser will implement WriterTo
by forwarding calls to r.
Go input arguments: (r Reader)
Go returns: ReadCloser
Joker input arguments: [^Reader r]
Joker returns: ^ReadCloser -
Pipe
Function v1.0(Pipe)
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.
Go returns: (*PipeReader, *PipeWriter)
Joker input arguments: []
Joker returns: [^*PipeReader, ^*PipeWriter] -
ReadAll
Function v1.0(ReadAll r)
ReadAll reads from r until an error or EOF and returns the data it read.
A successful call returns err == nil, not err == EOF. Because ReadAll is
defined to read from src until EOF, it does not treat an EOF from Read
as an error to be reported.
Go input arguments: (r Reader)
Go returns: ([]byte, error)
Joker input arguments: [^Reader r]
Joker returns: [^arrayOfByte, ^Error] -
ReadAtLeast
Function v1.0(ReadAtLeast r buf min)
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.
Go input arguments: (r Reader, buf []byte, min int)
Go returns: (n int, err error)
Joker input arguments: [^Reader r, ^arrayOfByte buf, ^Int min]
Joker returns: [^Int n, ^Error err] -
ReadFull
Function v1.0(ReadFull r buf)
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.
Go input arguments: (r Reader, buf []byte)
Go returns: (n int, err error)
Joker input arguments: [^Reader r, ^arrayOfByte buf]
Joker returns: [^Int n, ^Error err] -
TeeReader
Function v1.0(TeeReader r w)
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.
Go input arguments: (r Reader, w Writer)
Go returns: Reader
Joker input arguments: [^Reader r, ^Writer w]
Joker returns: ^Reader -
WriteString
Function v1.0(WriteString w s)
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.
Go input arguments: (w Writer, s string)
Go returns: (n int, err error)
Joker input arguments: [^Writer w, ^String s]
Joker returns: [^Int n, ^Error err]
Types
-
*LimitedReader
Concrete Type v1.0A 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.
-
Read
Receiver for *LimitedReader v1.0([p])
-
*PipeReader
Concrete Type v1.0A PipeReader is the read half of a pipe.
-
Close
Receiver for *PipeReader v1.0([])
Close closes the reader; subsequent writes to the
write half of the pipe will return the error ErrClosedPipe.
-
CloseWithError
Receiver for *PipeReader v1.0([err])
CloseWithError closes the reader; subsequent writes
to the write half of the pipe will return the error err.
CloseWithError never overwrites the previous error if it exists
and always returns nil.
-
Read
Receiver for *PipeReader v1.0([data])
Read implements the standard Read interface:
it reads data from the pipe, blocking until a writer
arrives or the write end is closed.
If the write end is closed with an error, that error is
returned as err; otherwise err is EOF.
-
*PipeWriter
Concrete Type v1.0A PipeWriter is the write half of a pipe.
-
Close
Receiver for *PipeWriter v1.0([])
Close closes the writer; subsequent reads from the
read half of the pipe will return no bytes and EOF.
-
CloseWithError
Receiver for *PipeWriter v1.0([err])
CloseWithError closes the writer; subsequent reads from the
read half of the pipe will return no bytes and the error err,
or EOF if err is nil.
CloseWithError never overwrites the previous error if it exists
and always returns nil.
-
Write
Receiver for *PipeWriter v1.0([data])
Write implements the standard Write interface:
it writes data to the pipe, blocking until one or more readers
have consumed all the data or the read end is closed.
If the read end is closed with an error, that err is
returned as err; otherwise err is ErrClosedPipe.
-
*SectionReader
Concrete Type v1.0SectionReader implements Read, Seek, and ReadAt on a section
of an underlying ReaderAt.
-
Read
Receiver for *SectionReader v1.0([p])
-
ReadAt
Receiver for *SectionReader v1.0([p off])
-
Seek
Receiver for *SectionReader v1.0([offset whence])
-
Size
Receiver for *SectionReader v1.0([])
Size returns the size of the section in bytes.
-
ByteReader
Abstract Type v1.0ByteReader 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.
-
ReadByte
Method for ByteReader v1.0([])
-
ByteScanner
Abstract Type v1.0ByteScanner is the interface that adds the UnreadByte method to the
basic ReadByte method.
UnreadByte causes the next call to ReadByte to return the last byte read.
If the last operation was not a successful call to ReadByte, UnreadByte may
return an error, unread the last byte read (or the byte prior to the
last-unread byte), or (in implementations that support the Seeker interface)
seek to one byte before the current offset.
-
ReadByte
Method for ByteScanner v1.0([])
-
UnreadByte
Method for ByteScanner v1.0([])
-
ByteWriter
Abstract Type v1.0ByteWriter is the interface that wraps the WriteByte method.
-
WriteByte
Method for ByteWriter v1.0([c])
-
Closer
Abstract Type v1.0Closer is the interface that wraps the basic Close method.
The behavior of Close after the first call is undefined.
Specific implementations may document their own behavior.
-
Close
Method for Closer v1.0([])
-
LimitedReader
Concrete Type v1.0A 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.
-
PipeReader
Concrete Type v1.0A PipeReader is the read half of a pipe.
-
PipeWriter
Concrete Type v1.0A PipeWriter is the write half of a pipe.
-
ReadCloser
Abstract Type v1.0ReadCloser is the interface that groups the basic Read and Close methods.
-
Close
Method for ReadCloser v1.0([])
-
Read
Method for ReadCloser v1.0([p])
-
ReadSeekCloser
Abstract Type v1.0ReadSeekCloser is the interface that groups the basic Read, Seek and Close
methods.
-
Close
Method for ReadSeekCloser v1.0([])
-
Read
Method for ReadSeekCloser v1.0([p])
-
Seek
Method for ReadSeekCloser v1.0([offset whence])
-
ReadSeeker
Abstract Type v1.0ReadSeeker is the interface that groups the basic Read and Seek methods.
-
Read
Method for ReadSeeker v1.0([p])
-
Seek
Method for ReadSeeker v1.0([offset whence])
-
ReadWriteCloser
Abstract Type v1.0ReadWriteCloser is the interface that groups the basic Read, Write and Close methods.
-
Close
Method for ReadWriteCloser v1.0([])
-
Read
Method for ReadWriteCloser v1.0([p])
-
Write
Method for ReadWriteCloser v1.0([p])
-
ReadWriteSeeker
Abstract Type v1.0ReadWriteSeeker is the interface that groups the basic Read, Write and Seek methods.
-
Read
Method for ReadWriteSeeker v1.0([p])
-
Seek
Method for ReadWriteSeeker v1.0([offset whence])
-
Write
Method for ReadWriteSeeker v1.0([p])
-
ReadWriter
Abstract Type v1.0ReadWriter is the interface that groups the basic Read and Write methods.
-
Read
Method for ReadWriter v1.0([p])
-
Write
Method for ReadWriter v1.0([p])
-
Reader
Abstract Type v1.0Reader is the interface that wraps the basic Read method.
Read reads up to len(p) bytes into p. It returns the number of bytes
read (0 <= n <= len(p)) and any error encountered. Even if Read
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, Read conventionally
returns what is available instead of waiting for more.
When Read encounters an error or end-of-file condition after
successfully reading n > 0 bytes, it returns the number of
bytes read. It may return the (non-nil) error from the same call
or return the error (and n == 0) from a subsequent call.
An instance of this general case is that a Reader returning
a non-zero number of bytes at the end of the input stream may
return either err == EOF or err == nil. The next Read should
return 0, EOF.
Callers should always process the n > 0 bytes returned before
considering the error err. Doing so correctly handles I/O errors
that happen after reading some bytes and also both of the
allowed EOF behaviors.
Implementations of Read are discouraged from returning a
zero byte count with a nil error, except when len(p) == 0.
Callers should treat a return of 0 and nil as indicating that
nothing happened; in particular it does not indicate EOF.
Implementations must not retain p.
-
Read
Method for Reader v1.0([p])
-
ReaderAt
Abstract Type v1.0ReaderAt 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.
-
ReadAt
Method for ReaderAt v1.0([p off])
-
ReaderFrom
Abstract Type v1.0ReaderFrom 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 EOF encountered during the read is also returned.
The Copy function uses ReaderFrom if available.
-
ReadFrom
Method for ReaderFrom v1.0([r])
-
RuneReader
Abstract Type v1.0RuneReader is the interface that wraps the ReadRune method.
ReadRune reads a single encoded Unicode character
and returns the rune and its size in bytes. If no character is
available, err will be set.
-
ReadRune
Method for RuneReader v1.0([])
-
RuneScanner
Abstract Type v1.0RuneScanner is the interface that adds the UnreadRune method to the
basic ReadRune method.
UnreadRune causes the next call to ReadRune to return the last rune read.
If the last operation was not a successful call to ReadRune, UnreadRune may
return an error, unread the last rune read (or the rune prior to the
last-unread rune), or (in implementations that support the Seeker interface)
seek to the start of the rune before the current offset.
-
ReadRune
Method for RuneScanner v1.0([])
-
UnreadRune
Method for RuneScanner v1.0([])
-
SectionReader
Concrete Type v1.0SectionReader implements Read, Seek, and ReadAt on a section
of an underlying ReaderAt.
-
Seeker
Abstract Type v1.0Seeker 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
(for example, offset = -2 specifies the penultimate byte of the file).
Seek returns the new offset relative to the start of the
file or an error, if any.
Seeking to an offset before the start of the file is an error.
Seeking to any positive offset may be allowed, but if the new offset exceeds
the size of the underlying object the behavior of subsequent I/O operations
is implementation-dependent.
-
Seek
Method for Seeker v1.0([offset whence])
-
StringWriter
Abstract Type v1.0StringWriter is the interface that wraps the WriteString method.
-
WriteString
Method for StringWriter v1.0([s])
-
WriteCloser
Abstract Type v1.0WriteCloser is the interface that groups the basic Write and Close methods.
-
Close
Method for WriteCloser v1.0([])
-
Write
Method for WriteCloser v1.0([p])
-
WriteSeeker
Abstract Type v1.0WriteSeeker is the interface that groups the basic Write and Seek methods.
-
Seek
Method for WriteSeeker v1.0([offset whence])
-
Write
Method for WriteSeeker v1.0([p])
-
Writer
Abstract Type v1.0Writer is the interface that wraps the basic Write method.
Write writes len(p) bytes from p to the underlying data stream.
It returns the number of bytes written from p (0 <= n <= len(p))
and any error encountered that caused the write to stop early.
Write must return a non-nil error if it returns n < len(p).
Write must not modify the slice data, even temporarily.
Implementations must not retain p.
-
Write
Method for Writer v1.0([p])
-
WriterAt
Abstract Type v1.0WriterAt 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.
-
WriteAt
Method for WriterAt v1.0([p off])
-
WriterTo
Abstract Type v1.0WriterTo 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.
-
WriteTo
Method for WriterTo v1.0([w])
-
arrayOfByteReader
Concrete Type v1.0ByteReader 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.
-
arrayOfByteScanner
Concrete Type v1.0ByteScanner is the interface that adds the UnreadByte method to the
basic ReadByte method.
UnreadByte causes the next call to ReadByte to return the last byte read.
If the last operation was not a successful call to ReadByte, UnreadByte may
return an error, unread the last byte read (or the byte prior to the
last-unread byte), or (in implementations that support the Seeker interface)
seek to one byte before the current offset.
-
arrayOfByteWriter
Concrete Type v1.0ByteWriter is the interface that wraps the WriteByte method.
-
arrayOfCloser
Concrete Type v1.0Closer is the interface that wraps the basic Close method.
The behavior of Close after the first call is undefined.
Specific implementations may document their own behavior.
-
arrayOfLimitedReader
Concrete Type v1.0A 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.
-
arrayOfPipeReader
Concrete Type v1.0A PipeReader is the read half of a pipe.
-
arrayOfPipeWriter
Concrete Type v1.0A PipeWriter is the write half of a pipe.
-
arrayOfReadCloser
Concrete Type v1.0ReadCloser is the interface that groups the basic Read and Close methods.
-
arrayOfReadSeekCloser
Concrete Type v1.0ReadSeekCloser is the interface that groups the basic Read, Seek and Close
methods.
-
arrayOfReadSeeker
Concrete Type v1.0ReadSeeker is the interface that groups the basic Read and Seek methods.
-
arrayOfReadWriteCloser
Concrete Type v1.0ReadWriteCloser is the interface that groups the basic Read, Write and Close methods.
-
arrayOfReadWriteSeeker
Concrete Type v1.0ReadWriteSeeker is the interface that groups the basic Read, Write and Seek methods.
-
arrayOfReadWriter
Concrete Type v1.0ReadWriter is the interface that groups the basic Read and Write methods.
-
arrayOfReader
Concrete Type v1.0Reader is the interface that wraps the basic Read method.
Read reads up to len(p) bytes into p. It returns the number of bytes
read (0 <= n <= len(p)) and any error encountered. Even if Read
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, Read conventionally
returns what is available instead of waiting for more.
When Read encounters an error or end-of-file condition after
successfully reading n > 0 bytes, it returns the number of
bytes read. It may return the (non-nil) error from the same call
or return the error (and n == 0) from a subsequent call.
An instance of this general case is that a Reader returning
a non-zero number of bytes at the end of the input stream may
return either err == EOF or err == nil. The next Read should
return 0, EOF.
Callers should always process the n > 0 bytes returned before
considering the error err. Doing so correctly handles I/O errors
that happen after reading some bytes and also both of the
allowed EOF behaviors.
Implementations of Read are discouraged from returning a
zero byte count with a nil error, except when len(p) == 0.
Callers should treat a return of 0 and nil as indicating that
nothing happened; in particular it does not indicate EOF.
Implementations must not retain p.
-
arrayOfReaderAt
Concrete Type v1.0ReaderAt 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.
-
arrayOfReaderFrom
Concrete Type v1.0ReaderFrom 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 EOF encountered during the read is also returned.
The Copy function uses ReaderFrom if available.
-
arrayOfRuneReader
Concrete Type v1.0RuneReader is the interface that wraps the ReadRune method.
ReadRune reads a single encoded Unicode character
and returns the rune and its size in bytes. If no character is
available, err will be set.
-
arrayOfRuneScanner
Concrete Type v1.0RuneScanner is the interface that adds the UnreadRune method to the
basic ReadRune method.
UnreadRune causes the next call to ReadRune to return the last rune read.
If the last operation was not a successful call to ReadRune, UnreadRune may
return an error, unread the last rune read (or the rune prior to the
last-unread rune), or (in implementations that support the Seeker interface)
seek to the start of the rune before the current offset.
-
arrayOfSectionReader
Concrete Type v1.0SectionReader implements Read, Seek, and ReadAt on a section
of an underlying ReaderAt.
-
arrayOfSeeker
Concrete Type v1.0Seeker 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
(for example, offset = -2 specifies the penultimate byte of the file).
Seek returns the new offset relative to the start of the
file or an error, if any.
Seeking to an offset before the start of the file is an error.
Seeking to any positive offset may be allowed, but if the new offset exceeds
the size of the underlying object the behavior of subsequent I/O operations
is implementation-dependent.
-
arrayOfStringWriter
Concrete Type v1.0StringWriter is the interface that wraps the WriteString method.
-
arrayOfWriteCloser
Concrete Type v1.0WriteCloser is the interface that groups the basic Write and Close methods.
-
arrayOfWriteSeeker
Concrete Type v1.0WriteSeeker is the interface that groups the basic Write and Seek methods.
-
arrayOfWriter
Concrete Type v1.0Writer is the interface that wraps the basic Write method.
Write writes len(p) bytes from p to the underlying data stream.
It returns the number of bytes written from p (0 <= n <= len(p))
and any error encountered that caused the write to stop early.
Write must return a non-nil error if it returns n < len(p).
Write must not modify the slice data, even temporarily.
Implementations must not retain p.
-
arrayOfWriterAt
Concrete Type v1.0WriterAt 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.
-
arrayOfWriterTo
Concrete Type v1.0WriterTo 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.