1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:54:40 -07:00

all: rename os.EOF to io.EOF in various non-code contexts

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5334050
This commit is contained in:
Vincent Vanackere 2011-11-03 14:01:30 -07:00 committed by Rob Pike
parent de03d502c7
commit eb1717e035
25 changed files with 39 additions and 39 deletions

View File

@ -105,7 +105,7 @@ Prefix Map key
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>
@ -133,7 +133,7 @@ Prefix Map key
(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>

View File

@ -825,7 +825,7 @@ func Contents(filename string) (string, error) {
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.

View File

@ -825,7 +825,7 @@ func Contents(filename string) (string, error) {
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.

View File

@ -29,7 +29,7 @@ var (
// tr := tar.NewReader(r)
// for {
// hdr, err := tr.Next()
// if err == os.EOF {
// if err == io.EOF {
// // end of tar archive
// break
// }
@ -200,7 +200,7 @@ func (tr *Reader) readHeader() *Header {
}
// 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 {

View File

@ -135,7 +135,7 @@ func (b *Reader) Peek(n int) ([]byte, error) {
// 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 {
@ -246,7 +246,7 @@ func (b *Reader) Buffered() int { return b.w - b.r }
// 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
@ -332,7 +332,7 @@ func (b *Reader) ReadLine() (line []byte, isPrefix bool, 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 *Reader) ReadBytes(delim byte) (line []byte, err error) {
@ -379,7 +379,7 @@ 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) {

View File

@ -117,7 +117,7 @@ const MinRead = 512
// 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
@ -200,7 +200,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) {
// 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
@ -236,7 +236,7 @@ func (b *Buffer) Next(n int) []byte {
}
// 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) {
@ -252,7 +252,7 @@ func (b *Buffer) ReadByte() (c byte, err error) {
// 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) {
@ -307,7 +307,7 @@ func (b *Buffer) UnreadByte() 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) {
@ -326,7 +326,7 @@ 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) {

View File

@ -151,7 +151,7 @@ func (r *openpgpReader) Read(p []byte) (n int, 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) {

View File

@ -471,7 +471,7 @@ Again:
// 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() {

View File

@ -197,7 +197,7 @@ func NewParser(r io.Reader) *Parser {
}
// 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

View File

@ -520,7 +520,7 @@ func TestTrailingRawToken(t *testing.T) {
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)
}
}
@ -531,7 +531,7 @@ func TestTrailingToken(t *testing.T) {
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)
}
}
@ -542,7 +542,7 @@ func TestEntityInsideCDATA(t *testing.T) {
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)
}
}

View File

@ -219,7 +219,7 @@ func (s *ss) getRune() (r rune) {
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) {

View File

@ -36,7 +36,7 @@ lower-cased, and attributes are collected into a []Attribute. For example:
for {
if z.Next() == html.ErrorToken {
// Returning os.EOF indicates success.
// Returning io.EOF indicates success.
return z.Error()
}
emitToken(z.Token())

View File

@ -123,7 +123,7 @@ type Tokenizer struct {
// 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
@ -150,7 +150,7 @@ type Tokenizer struct {
}
// 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

View File

@ -516,7 +516,7 @@ func (z *Int) SetString(s string, base int) (*Int, bool) {
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

View File

@ -176,7 +176,7 @@ type Reader struct {
}
// 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()

View File

@ -214,7 +214,7 @@ func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) {
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)
}
}
@ -259,7 +259,7 @@ func TestVariousTextLineEndings(t *testing.T) {
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)
}
}

View File

@ -67,7 +67,7 @@ func (cw *chunkedWriter) Close() error {
// 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.

View File

@ -824,7 +824,7 @@ func TestRedirectMunging(t *testing.T) {
// 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)

View File

@ -147,7 +147,7 @@ func TestShutdown(t *testing.T) {
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()

View File

@ -299,7 +299,7 @@ func (r *Reader) ReadResponse(expectCode int) (code int, message string, err err
//
// 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()

View File

@ -19,7 +19,7 @@ const (
//
// 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

View File

@ -136,7 +136,7 @@ func Lstat(name string) (fi *FileInfo, err error) {
//
// 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

View File

@ -126,7 +126,7 @@ func (file *File) Close() error {
//
// 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

View File

@ -235,7 +235,7 @@ func (s *Scanner) next() rune {
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)

View File

@ -58,7 +58,7 @@ func (r *Reader) UnreadByte() error {
// 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) {