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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // UnreadByte causes the next call to ReadByte to return the same byte | 210 // UnreadByte causes the next call to ReadByte to return the same byte |
211 // as the previous call to ReadByte. | 211 // as the previous call to ReadByte. |
212 // It may be an error to call UnreadByte twice without an intervening | 212 // It may be an error to call UnreadByte twice without an intervening |
213 // call to ReadByte. | 213 // call to ReadByte. |
214 type ByteScanner interface { | 214 type ByteScanner interface { |
215 ByteReader | 215 ByteReader |
216 UnreadByte() error | 216 UnreadByte() error |
217 } | 217 } |
218 | 218 |
219 // ByteWriter is the interface that wraps the WriteByte method. | 219 // ByteWriter is the interface that wraps the WriteByte method. |
220 // | |
221 // WriteByte efficiently writes a single byte, relative to the | |
222 // equivalent Write call. Implementation of ByteWriter generally | |
223 // are buffered in-memory. | |
224 type ByteWriter interface { | 220 type ByteWriter interface { |
225 WriteByte(c byte) error | 221 WriteByte(c byte) error |
226 } | 222 } |
227 | 223 |
228 // RuneReader is the interface that wraps the ReadRune method. | 224 // RuneReader is the interface that wraps the ReadRune method. |
229 // | 225 // |
230 // ReadRune reads a single UTF-8 encoded Unicode character | 226 // ReadRune reads a single UTF-8 encoded Unicode character |
231 // and returns the rune and its size in bytes. If no character is | 227 // and returns the rune and its size in bytes. If no character is |
232 // available, err will be set. | 228 // available, err will be set. |
233 type RuneReader interface { | 229 type RuneReader interface { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 491 |
496 func (t *teeReader) Read(p []byte) (n int, err error) { | 492 func (t *teeReader) Read(p []byte) (n int, err error) { |
497 n, err = t.r.Read(p) | 493 n, err = t.r.Read(p) |
498 if n > 0 { | 494 if n > 0 { |
499 if n, err := t.w.Write(p[:n]); err != nil { | 495 if n, err := t.w.Write(p[:n]); err != nil { |
500 return n, err | 496 return n, err |
501 } | 497 } |
502 } | 498 } |
503 return | 499 return |
504 } | 500 } |
LEFT | RIGHT |