]> Cypherpunks repositories - gostls13.git/commitdiff
move ShortWrite error into io so that other packages can use it.
authorRuss Cox <rsc@golang.org>
Mon, 18 May 2009 18:47:35 +0000 (11:47 -0700)
committerRuss Cox <rsc@golang.org>
Mon, 18 May 2009 18:47:35 +0000 (11:47 -0700)
R=r
DELTA=15  (7 added, 1 deleted, 7 changed)
OCL=28996
CL=28996

src/lib/bufio/bufio.go
src/lib/http/server.go
src/lib/io/io.go

index f0e12931da231f1588fbf3cc6e46e2149d8970bc..3b4aeb820226cf7e7e343d95779580dfa5632434 100644 (file)
@@ -30,11 +30,10 @@ type Error struct {
 }
 
 var (
-       PhaseError os.Error = &Error{"phase error"};
-       BufferFull os.Error = &Error{"buffer full"};
-       InternalError os.Error = &Error{"bufio internal error"};
-       BadBufSize os.Error = &Error{"bad bufio size"};
-       ShortWrite os.Error = &Error{"short write"};
+       PhaseError os.Error = &Error{"bufio: phase error"};
+       BufferFull os.Error = &Error{"bufio: buffer full"};
+       InternalError os.Error = &Error{"bufio: internal error"};
+       BadBufSize os.Error = &Error{"bufio: bad buffer size"};
 )
 
 func copySlice(dst []byte, src []byte) {
@@ -427,7 +426,7 @@ func (b *Writer) Flush() os.Error {
                m, e := b.wr.Write(b.buf[n:b.n]);
                n += m;
                if m == 0 && e == nil {
-                       e = ShortWrite
+                       e = io.ErrShortWrite
                }
                if e != nil {
                        if n < b.n {
index bdac8f188cfcff627a99541ec30190815435470e..3758182357132d209aa6da0cd198567671581dab 100644 (file)
@@ -177,7 +177,7 @@ func (c *Conn) Write(data []byte) (n int, err os.Error) {
        n, err = c.buf.Write(data);
        if err == nil && c.chunking {
                if n != len(data) {
-                       err = bufio.ShortWrite;
+                       err = io.ErrShortWrite;
                }
                if err == nil {
                        io.WriteString(c.buf, "\r\n");
index b283593596de173af0f1a877ac64d3b67d8d921c..70c82d56293de8f330e6f7d31e474ee2eeeb6634 100644 (file)
@@ -13,12 +13,19 @@ import (
        "os";
 )
 
-// ErrEOF is the error returned by FullRead and Copyn when they encounter EOF.
+// Error represents an unexpected I/O behavior.
 type Error struct {
        os.ErrorString
 }
+
+// ErrEOF means that data was expected, but a read got EOF instead.
 var ErrEOF os.Error = &Error{"EOF"}
 
+// ErrShortWrite means that a write accepted fewer bytes than requested
+// but failed to return an explicit error.
+var ErrShortWrite os.Error = &Error{"short write"}
+
+
 // Reader is the interface that wraps the basic Read method.
 type Reader interface {
        Read(p []byte) (n int, err os.Error);