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

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

Issue 87780046: code review 87780046: io: document that a Writer must not write to p (Closed)
Left Patch Set: diff -r 8e5787506b59 https://go.googlecode.com/hg/ Created 10 years, 11 months ago
Right Patch Set: diff -r b7951abc878e https://go.googlecode.com/hg/ Created 10 years, 11 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
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