]> Cypherpunks repositories - gostls13.git/commitdiff
io: unexport ErrBadWriteCount
authorRuss Cox <rsc@golang.org>
Fri, 16 Oct 2020 03:32:51 +0000 (23:32 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 16 Oct 2020 17:52:59 +0000 (17:52 +0000)
It was added in CL 240740 to fix #39978
but without any discussion of the exported API.

The error can still be returned to fix the issue,
without adding new public API to package io.

Also fix the error message to refer to lower-case write
like the other errors in the package.

Change-Id: I134de5eaf3ac903d73913c5cadcde904c5255d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/262877
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

src/io/export_test.go [new file with mode: 0644]
src/io/io.go
src/io/io_test.go

diff --git a/src/io/export_test.go b/src/io/export_test.go
new file mode 100644 (file)
index 0000000..fa3e8e7
--- /dev/null
@@ -0,0 +1,8 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io
+
+// exported for test
+var ErrInvalidWrite = errInvalidWrite
index 4bd1ae913af94036c6f18cf7fa9486d8b9ca3702..a34c39a32a41528f483f47da75ce212b1e209630 100644 (file)
@@ -27,12 +27,12 @@ const (
 // but failed to return an explicit error.
 var ErrShortWrite = errors.New("short write")
 
+// errInvalidWrite means that a write returned an impossible count.
+var errInvalidWrite = errors.New("invalid write result")
+
 // ErrShortBuffer means that a read required a longer buffer than was provided.
 var ErrShortBuffer = errors.New("short buffer")
 
-// ErrBadWriteCount means that a write returned an impossible count.
-var ErrBadWriteCount = errors.New("Write returned impossible count")
-
 // EOF 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 ==.)
@@ -425,7 +425,7 @@ func copyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
                        if nw < 0 || nr < nw {
                                nw = 0
                                if ew == nil {
-                                       ew = ErrBadWriteCount
+                                       ew = errInvalidWrite
                                }
                        }
                        written += int64(nw)
index a8399bcac60213271fb63fcdd549e9c04fb9dbb0..5b355e8c55b1692eb543cdc66cbed0593bb6efd4 100644 (file)
@@ -441,7 +441,7 @@ func (w largeWriter) Write(p []byte) (int, error) {
 }
 
 func TestCopyLargeWriter(t *testing.T) {
-       want := ErrBadWriteCount
+       want := ErrInvalidWrite
        rb := new(Buffer)
        wb := largeWriter{}
        rb.WriteString("hello, world.")