reads space-separated values from an <code>io.Reader</code>.
<br/><br/>
The <code>Build</code> method returns once the <code>Reader</code>'s
- <code>Read</code> method returns <code>os.EOF</code> (end of file)
+ <code>Read</code> method returns <code>io.EOF</code> (end of file)
or some other read error occurs.
</step>
(including punctuation), which is exactly what we need.
<br/><br/>
<code>Fscan</code> returns an error if it encounters a read error
- (<code>os.EOF</code>, for example) or if it can't scan the requested
+ (<code>io.EOF</code>, for example) or if it can't scan the requested
value (in our case, a single string). In either case we just want to
stop scanning, so we <code>break</code> out of the loop.
</step>
n, err := f.Read(buf[0:])
result = append(result, buf[0:n]...) // append is discussed later.
if err != nil {
- if err == os.EOF {
+ if err == io.EOF {
break
}
return "", err // f will be closed if we return here.
n, err := f.Read(buf[0:])
result = append(result, buf[0:n]...) // append is discussed later.
if err != nil {
- if err == os.EOF {
+ if err == io.EOF {
break
}
return "", err // f will be closed if we return here.
// tr := tar.NewReader(r)
// for {
// hdr, err := tr.Next()
-// if err == os.EOF {
+// if err == io.EOF {
// // end of tar archive
// break
// }
}
// Read reads from the current entry in the tar archive.
-// It returns 0, os.EOF when it reaches the end of that entry,
+// It returns 0, io.EOF when it reaches the end of that entry,
// until Next is called to advance to the next entry.
func (tr *Reader) Read(b []byte) (n int, err error) {
if tr.nb == 0 {
// It returns the number of bytes read into p.
// It calls Read at most once on the underlying Reader,
// hence n may be less than len(p).
-// At EOF, the count will be zero and err will be os.EOF.
+// At EOF, the count will be zero and err will be io.EOF.
func (b *Reader) Read(p []byte) (n int, err error) {
n = len(p)
if n == 0 {
// returning a slice pointing at the bytes in the buffer.
// The bytes stop being valid at the next read call.
// If ReadSlice encounters an error before finding a delimiter,
-// it returns all the data in the buffer and the error itself (often os.EOF).
+// it returns all the data in the buffer and the error itself (often io.EOF).
// ReadSlice fails with error ErrBufferFull if the buffer fills without a delim.
// Because the data returned from ReadSlice will be overwritten
// by the next I/O operation, most clients should use
// ReadBytes reads until the first occurrence of delim in the input,
// returning a slice containing the data up to and including the delimiter.
// If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadBytes returns err != nil if and only if the returned data does not end in
// delim.
func (b *Reader) ReadBytes(delim byte) (line []byte, err error) {
// ReadString reads until the first occurrence of delim in the input,
// returning a string containing the data up to and including the delimiter.
// If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadString returns err != nil if and only if the returned data does not end in
// delim.
func (b *Reader) ReadString(delim byte) (line string, err error) {
// ReadFrom reads data from r until EOF and appends it to the buffer.
// The return value n is the number of bytes read.
-// Any error except os.EOF encountered during the read
+// Any error except io.EOF encountered during the read
// is also returned.
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
// Read reads the next len(p) bytes from the buffer or until the buffer
// is drained. The return value n is the number of bytes read. If the
-// buffer has no data to return, err is os.EOF even if len(p) is zero;
+// buffer has no data to return, err is io.EOF even if len(p) is zero;
// otherwise it is nil.
func (b *Buffer) Read(p []byte) (n int, err error) {
b.lastRead = opInvalid
}
// ReadByte reads and returns the next byte from the buffer.
-// If no byte is available, it returns error os.EOF.
+// If no byte is available, it returns error io.EOF.
func (b *Buffer) ReadByte() (c byte, err error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
// ReadRune reads and returns the next UTF-8-encoded
// Unicode code point from the buffer.
-// If no bytes are available, the error returned is os.EOF.
+// If no bytes are available, the error returned is io.EOF.
// If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1.
func (b *Buffer) ReadRune() (r rune, size int, err error) {
// ReadBytes reads until the first occurrence of delim in the input,
// returning a slice containing the data up to and including the delimiter.
// If ReadBytes encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadBytes returns err != nil if and only if the returned data does not end in
// delim.
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) {
// ReadString reads until the first occurrence of delim in the input,
// returning a string containing the data up to and including the delimiter.
// If ReadString encounters an error before finding a delimiter,
-// it returns the data read before the error and the error itself (often os.EOF).
+// it returns the data read before the error and the error itself (often io.EOF).
// ReadString returns err != nil if and only if the returned data does not end
// in delim.
func (b *Buffer) ReadString(delim byte) (line string, err error) {
}
// Decode reads a PGP armored block from the given Reader. It will ignore
-// leading garbage. If it doesn't find a block, it will return nil, os.EOF. The
+// leading garbage. If it doesn't find a block, it will return nil, io.EOF. The
// given Reader is not usable after calling this function: an arbitrary amount
// of data may have been read past the end of the block.
func Decode(in io.Reader) (p *Block, err error) {
// RFC suggests that EOF without an alertCloseNotify is
// an error, but popular web sites seem to do this,
// so we can't make it an error.
- // if err == os.EOF {
+ // if err == io.EOF {
// err = io.ErrUnexpectedEOF
// }
if e, ok := err.(net.Error); !ok || !e.Temporary() {
}
// Token returns the next XML token in the input stream.
-// At the end of the input stream, Token returns nil, os.EOF.
+// At the end of the input stream, Token returns nil, io.EOF.
//
// Slices of bytes in the returned token data refer to the
// parser's internal buffer and remain valid only until the next
for _, err = p.RawToken(); err == nil; _, err = p.RawToken() {
}
if err != io.EOF {
- t.Fatalf("p.RawToken() = _, %v, want _, os.EOF", err)
+ t.Fatalf("p.RawToken() = _, %v, want _, io.EOF", err)
}
}
for _, err = p.Token(); err == nil; _, err = p.Token() {
}
if err != io.EOF {
- t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
+ t.Fatalf("p.Token() = _, %v, want _, io.EOF", err)
}
}
for _, err = p.Token(); err == nil; _, err = p.Token() {
}
if err != io.EOF {
- t.Fatalf("p.Token() = _, %v, want _, os.EOF", err)
+ t.Fatalf("p.Token() = _, %v, want _, io.EOF", err)
}
}
return
}
-// mustReadRune turns os.EOF into a panic(io.ErrUnexpectedEOF).
+// mustReadRune turns io.EOF into a panic(io.ErrUnexpectedEOF).
// It is called in cases such as string scanning where an EOF is a
// syntax error.
func (s *ss) mustReadRune() (r rune) {
for {
if z.Next() == html.ErrorToken {
- // Returning os.EOF indicates success.
+ // Returning io.EOF indicates success.
return z.Error()
}
emitToken(z.Token())
// for tt != Error && err != nil to hold: this means that Next returned a
// valid token but the subsequent Next call will return an error token.
// For example, if the HTML text input was just "plain", then the first
- // Next call would set z.err to os.EOF but return a TextToken, and all
+ // Next call would set z.err to io.EOF but return a TextToken, and all
// subsequent Next calls would return an ErrorToken.
// err is never reset. Once it becomes non-nil, it stays non-nil.
err error
}
// Error returns the error associated with the most recent ErrorToken token.
-// This is typically os.EOF, meaning the end of tokenization.
+// This is typically io.EOF, meaning the end of tokenization.
func (z *Tokenizer) Error() error {
if z.tt != ErrorToken {
return nil
if err != io.EOF {
return nil, false
}
- return z, true // err == os.EOF => scan consumed all of s
+ return z, true // err == io.EOF => scan consumed all of s
}
// SetBytes interprets buf as the bytes of a big-endian unsigned
}
// NextPart returns the next part in the multipart or an error.
-// When there are no more parts, the error os.EOF is returned.
+// When there are no more parts, the error io.EOF is returned.
func (mr *Reader) NextPart() (*Part, error) {
if mr.currentPart != nil {
mr.currentPart.Close()
t.Error("Didn't expect a fifth part.")
}
if err != io.EOF {
- t.Errorf("On fifth part expected os.EOF; got %v", err)
+ t.Errorf("On fifth part expected io.EOF; got %v", err)
}
}
t.Errorf("Unexpected part in test %d", testNum)
}
if err != io.EOF {
- t.Errorf("On test %d expected os.EOF; got %v", testNum, err)
+ t.Errorf("On test %d expected io.EOF; got %v", testNum, err)
}
}
// NewChunkedReader returns a new reader that translates the data read from r
// out of HTTP "chunked" format before returning it.
-// The reader returns os.EOF when the final 0-length chunk is read.
+// The reader returns io.EOF when the final 0-length chunk is read.
//
// NewChunkedReader is not needed by normal applications. The http package
// automatically decodes chunking when reading response bodies.
// explicit Content-Length of zero is present), then the transport can re-use the
// connection immediately. But when it re-uses the connection, it typically closes
// the previous request's body, which is not optimal for zero-lengthed bodies,
-// as the client would then see http.ErrBodyReadAfterClose and not 0, os.EOF.
+// as the client would then see http.ErrBodyReadAfterClose and not 0, io.EOF.
func TestZeroLengthPostAndResponse(t *testing.T) {
ts := httptest.NewServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
all, err := ioutil.ReadAll(r.Body)
var buf [10]byte
n, err := c.Read(buf[:])
if n != 0 || err != io.EOF {
- t.Fatalf("server Read = %d, %v; want 0, os.EOF", n, err)
+ t.Fatalf("server Read = %d, %v; want 0, io.EOF", n, err)
}
c.Write([]byte("response"))
c.Close()
//
// The decoded form returned by the Reader's Read method
// rewrites the "\r\n" line endings into the simpler "\n",
-// removes leading dot escapes if present, and stops with error os.EOF
+// removes leading dot escapes if present, and stops with error io.EOF
// after consuming (and discarding) the end-of-sequence line.
func (r *Reader) DotReader() io.Reader {
r.closeDot()
//
// If n > 0, Readdirnames returns at most n names. In this case, if
// Readdirnames returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
+// explaining why. At the end of a directory, the error is io.EOF.
//
// If n <= 0, Readdirnames returns all the names from the directory in
// a single slice. In this case, if Readdirnames succeeds (reads all
//
// If n > 0, Readdir returns at most n FileInfo structures. In this case, if
// Readdir returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
+// explaining why. At the end of a directory, the error is io.EOF.
//
// If n <= 0, Readdir returns all the FileInfo from the directory in
// a single slice. In this case, if Readdir succeeds (reads all
//
// If n > 0, Readdir returns at most n FileInfo structures. In this case, if
// Readdir returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
+// explaining why. At the end of a directory, the error is io.EOF.
//
// If n <= 0, Readdir returns all the FileInfo from the directory in
// a single slice. In this case, if Readdir succeeds (reads all
copy(s.srcBuf[0:], s.srcBuf[s.srcPos:s.srcEnd])
s.srcBufOffset += s.srcPos
// read more bytes
- // (an io.Reader must return os.EOF when it reaches
+ // (an io.Reader must return io.EOF when it reaches
// the end of what it is reading - simply returning
// n == 0 will make this loop retry forever; but the
// error is in the reader implementation in that case)
// ReadRune reads and returns the next UTF-8-encoded
// Unicode code point from the buffer.
-// If no bytes are available, the error returned is os.EOF.
+// If no bytes are available, the error returned is io.EOF.
// If the bytes are an erroneous UTF-8 encoding, it
// consumes one byte and returns U+FFFD, 1.
func (r *Reader) ReadRune() (ch rune, size int, err error) {