Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Package io provides basic interfaces to I/O primitives. | 5 // Package io provides basic interfaces to I/O primitives. |
6 // Its primary job is to wrap existing implementations of such primitives, | 6 // Its primary job is to wrap existing implementations of such primitives, |
7 // such as those in package os, into shared public interfaces that | 7 // such as those in package os, into shared public interfaces that |
8 // abstract the functionality, plus some other related primitives. | 8 // abstract the functionality, plus some other related primitives. |
9 // | 9 // |
10 // Because these interfaces and primitives wrap lower-level operations with | 10 // Because these interfaces and primitives wrap lower-level operations with |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 type Reader interface { | 67 type Reader interface { |
68 Read(p []byte) (n int, err error) | 68 Read(p []byte) (n int, err error) |
69 } | 69 } |
70 | 70 |
71 // Writer is the interface that wraps the basic Write method. | 71 // Writer is the interface that wraps the basic Write method. |
72 // | 72 // |
73 // Write writes len(p) bytes from p to the underlying data stream. | 73 // Write writes len(p) bytes from p to the underlying data stream. |
74 // It returns the number of bytes written from p (0 <= n <= len(p)) | 74 // It returns the number of bytes written from p (0 <= n <= len(p)) |
75 // and any error encountered that caused the write to stop early. | 75 // and any error encountered that caused the write to stop early. |
76 // Write must return a non-nil error if it returns n < len(p). | 76 // Write must return a non-nil error if it returns n < len(p). |
77 // Write must not write to the slice p. | 77 // Write must not modify the slice data, even temporarily. |
r
2014/04/15 22:49:58
I'm sorry but "Write must not write..." is odd and
bradfitz
2014/04/15 22:55:56
I still object.
There's a difference between leav
r
2014/04/15 22:57:34
Sigh. Well, at least if we use 'it' we don't have
| |
78 type Writer interface { | 78 type Writer interface { |
79 Write(p []byte) (n int, err error) | 79 Write(p []byte) (n int, err error) |
80 } | 80 } |
81 | 81 |
82 // Closer is the interface that wraps the basic Close method. | 82 // Closer is the interface that wraps the basic Close method. |
83 // | 83 // |
84 // The behavior of Close after the first call is undefined. | 84 // The behavior of Close after the first call is undefined. |
85 // Specific implementations may document their own behavior. | 85 // Specific implementations may document their own behavior. |
86 type Closer interface { | 86 type Closer interface { |
87 Close() error | 87 Close() error |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 | 484 |
485 func (t *teeReader) Read(p []byte) (n int, err error) { | 485 func (t *teeReader) Read(p []byte) (n int, err error) { |
486 n, err = t.r.Read(p) | 486 n, err = t.r.Read(p) |
487 if n > 0 { | 487 if n > 0 { |
488 if n, err := t.w.Write(p[:n]); err != nil { | 488 if n, err := t.w.Write(p[:n]); err != nil { |
489 return n, err | 489 return n, err |
490 } | 490 } |
491 } | 491 } |
492 return | 492 return |
493 } | 493 } |
LEFT | RIGHT |