From eb1717e035e9c6b6690fd55b6396f99b40d26d3f Mon Sep 17 00:00:00 2001 From: Vincent Vanackere Date: Thu, 3 Nov 2011 14:01:30 -0700 Subject: [PATCH] all: rename os.EOF to io.EOF in various non-code contexts R=golang-dev, r CC=golang-dev https://golang.org/cl/5334050 --- doc/codewalk/markov.xml | 4 ++-- doc/effective_go.html | 2 +- doc/effective_go.tmpl | 2 +- src/pkg/archive/tar/reader.go | 4 ++-- src/pkg/bufio/bufio.go | 8 ++++---- src/pkg/bytes/buffer.go | 12 ++++++------ src/pkg/crypto/openpgp/armor/armor.go | 2 +- src/pkg/crypto/tls/conn.go | 2 +- src/pkg/encoding/xml/xml.go | 2 +- src/pkg/encoding/xml/xml_test.go | 6 +++--- src/pkg/fmt/scan.go | 2 +- src/pkg/html/doc.go | 2 +- src/pkg/html/token.go | 4 ++-- src/pkg/math/big/int.go | 2 +- src/pkg/mime/multipart/multipart.go | 2 +- src/pkg/mime/multipart/multipart_test.go | 4 ++-- src/pkg/net/http/chunked.go | 2 +- src/pkg/net/http/serve_test.go | 2 +- src/pkg/net/net_test.go | 2 +- src/pkg/net/textproto/reader.go | 2 +- src/pkg/os/dir_unix.go | 2 +- src/pkg/os/file_unix.go | 2 +- src/pkg/os/file_windows.go | 2 +- src/pkg/scanner/scanner.go | 2 +- src/pkg/strings/reader.go | 2 +- 25 files changed, 39 insertions(+), 39 deletions(-) diff --git a/doc/codewalk/markov.xml b/doc/codewalk/markov.xml index a89b4d0ce8c..81df1289c21 100644 --- a/doc/codewalk/markov.xml +++ b/doc/codewalk/markov.xml @@ -105,7 +105,7 @@ Prefix Map key reads space-separated values from an io.Reader.

The Build method returns once the Reader's - Read method returns os.EOF (end of file) + Read method returns io.EOF (end of file) or some other read error occurs. @@ -133,7 +133,7 @@ Prefix Map key (including punctuation), which is exactly what we need.

Fscan returns an error if it encounters a read error - (os.EOF, for example) or if it can't scan the requested + (io.EOF, 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 break out of the loop. diff --git a/doc/effective_go.html b/doc/effective_go.html index 8267564740c..a58989ab553 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -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. diff --git a/doc/effective_go.tmpl b/doc/effective_go.tmpl index aa011f2a014..842f026e107 100644 --- a/doc/effective_go.tmpl +++ b/doc/effective_go.tmpl @@ -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. diff --git a/src/pkg/archive/tar/reader.go b/src/pkg/archive/tar/reader.go index 65bf1204ab4..facba2cc7a3 100644 --- a/src/pkg/archive/tar/reader.go +++ b/src/pkg/archive/tar/reader.go @@ -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 { diff --git a/src/pkg/bufio/bufio.go b/src/pkg/bufio/bufio.go index 0b354fda82f..7c4f90d85c1 100644 --- a/src/pkg/bufio/bufio.go +++ b/src/pkg/bufio/bufio.go @@ -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) { diff --git a/src/pkg/bytes/buffer.go b/src/pkg/bytes/buffer.go index fbfd6210b64..d1a5b68dc81 100644 --- a/src/pkg/bytes/buffer.go +++ b/src/pkg/bytes/buffer.go @@ -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) { diff --git a/src/pkg/crypto/openpgp/armor/armor.go b/src/pkg/crypto/openpgp/armor/armor.go index 707bdf354b3..3bbb5dc351a 100644 --- a/src/pkg/crypto/openpgp/armor/armor.go +++ b/src/pkg/crypto/openpgp/armor/armor.go @@ -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) { diff --git a/src/pkg/crypto/tls/conn.go b/src/pkg/crypto/tls/conn.go index 6312c34d6d7..f4178e30c58 100644 --- a/src/pkg/crypto/tls/conn.go +++ b/src/pkg/crypto/tls/conn.go @@ -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() { diff --git a/src/pkg/encoding/xml/xml.go b/src/pkg/encoding/xml/xml.go index d534c52c1ca..525635067e1 100644 --- a/src/pkg/encoding/xml/xml.go +++ b/src/pkg/encoding/xml/xml.go @@ -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 diff --git a/src/pkg/encoding/xml/xml_test.go b/src/pkg/encoding/xml/xml_test.go index 1b40d0c4d41..6c874fadb7a 100644 --- a/src/pkg/encoding/xml/xml_test.go +++ b/src/pkg/encoding/xml/xml_test.go @@ -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) } } diff --git a/src/pkg/fmt/scan.go b/src/pkg/fmt/scan.go index 54a9fe2951e..7ac3b8edcc1 100644 --- a/src/pkg/fmt/scan.go +++ b/src/pkg/fmt/scan.go @@ -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) { diff --git a/src/pkg/html/doc.go b/src/pkg/html/doc.go index ba9d188486f..0620679bd64 100644 --- a/src/pkg/html/doc.go +++ b/src/pkg/html/doc.go @@ -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()) diff --git a/src/pkg/html/token.go b/src/pkg/html/token.go index c5b8a1c710e..9213844728b 100644 --- a/src/pkg/html/token.go +++ b/src/pkg/html/token.go @@ -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 diff --git a/src/pkg/math/big/int.go b/src/pkg/math/big/int.go index c6affbbdaeb..f325723804f 100644 --- a/src/pkg/math/big/int.go +++ b/src/pkg/math/big/int.go @@ -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 diff --git a/src/pkg/mime/multipart/multipart.go b/src/pkg/mime/multipart/multipart.go index 24b0e41cae1..64a11e6d9d9 100644 --- a/src/pkg/mime/multipart/multipart.go +++ b/src/pkg/mime/multipart/multipart.go @@ -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() diff --git a/src/pkg/mime/multipart/multipart_test.go b/src/pkg/mime/multipart/multipart_test.go index dd5d7c12f7f..ce2a27c4413 100644 --- a/src/pkg/mime/multipart/multipart_test.go +++ b/src/pkg/mime/multipart/multipart_test.go @@ -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) } } diff --git a/src/pkg/net/http/chunked.go b/src/pkg/net/http/chunked.go index 157e1c46c3b..76beb15c348 100644 --- a/src/pkg/net/http/chunked.go +++ b/src/pkg/net/http/chunked.go @@ -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. diff --git a/src/pkg/net/http/serve_test.go b/src/pkg/net/http/serve_test.go index 98e10d433e8..21273711bba 100644 --- a/src/pkg/net/http/serve_test.go +++ b/src/pkg/net/http/serve_test.go @@ -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) diff --git a/src/pkg/net/net_test.go b/src/pkg/net/net_test.go index d2839d719fd..0dc86698e10 100644 --- a/src/pkg/net/net_test.go +++ b/src/pkg/net/net_test.go @@ -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() diff --git a/src/pkg/net/textproto/reader.go b/src/pkg/net/textproto/reader.go index 658b5c282ec..793c6c2c83e 100644 --- a/src/pkg/net/textproto/reader.go +++ b/src/pkg/net/textproto/reader.go @@ -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() diff --git a/src/pkg/os/dir_unix.go b/src/pkg/os/dir_unix.go index e59c1af2ea7..a16bcf63f41 100644 --- a/src/pkg/os/dir_unix.go +++ b/src/pkg/os/dir_unix.go @@ -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 diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go index f4038168fcc..02ba3162304 100644 --- a/src/pkg/os/file_unix.go +++ b/src/pkg/os/file_unix.go @@ -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 diff --git a/src/pkg/os/file_windows.go b/src/pkg/os/file_windows.go index a8c36cb1bc5..d6a065de544 100644 --- a/src/pkg/os/file_windows.go +++ b/src/pkg/os/file_windows.go @@ -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 diff --git a/src/pkg/scanner/scanner.go b/src/pkg/scanner/scanner.go index 5ab37792d4c..9e230174ca0 100644 --- a/src/pkg/scanner/scanner.go +++ b/src/pkg/scanner/scanner.go @@ -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) diff --git a/src/pkg/strings/reader.go b/src/pkg/strings/reader.go index ac8d9dcdf8e..4f24b5b6380 100644 --- a/src/pkg/strings/reader.go +++ b/src/pkg/strings/reader.go @@ -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) {