Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2710)

Delta Between Two Patch Sets: src/pkg/io/io.go

Issue 6760045: code review 6760045: io: add ByteWriter interface (Closed)
Left Patch Set: diff -r d81bcf447d65 https://go.googlecode.com/hg/ Created 12 years, 5 months ago
Right Patch Set: diff -r 959dee37d03d https://go.googlecode.com/hg/ Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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.
r 2012/10/29 21:14:15 two weasel-word adverbs in two sentences. the inte
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
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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b