Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io: CopyBuffer should document when buf is not used #32276

Closed
sandyskies opened this issue May 28, 2019 · 3 comments
Closed

io: CopyBuffer should document when buf is not used #32276

sandyskies opened this issue May 28, 2019 · 3 comments
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.

Comments

@sandyskies
Copy link
Contributor

The follow is the comment for io.CopyBuffer,
// CopyBuffer is identical to Copy except that it stages through the
// provided buffer (if one is required) rather than allocating a
// temporary one. If buf is nil, one is allocated; otherwise if it has
// zero length, CopyBuffer panics.
func CopyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error)

which is not precise enough, in the case of src implements the WriterTo interface or the case of if dst implements the ReaderFrom interface , buf will be ignore ,which is not mentioned at all. Which is very easy to lead people to wrong way.

@bcmills bcmills added Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 28, 2019
@bcmills
Copy link
Contributor

bcmills commented May 28, 2019

This closely relates to #16474.

@sandyskies
Copy link
Contributor Author

@bcmills Before the API is changed, we should add more comment to explain the behavior. This PR
is for adding the comment. #32279

@bcmills bcmills added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 29, 2019
@odeke-em odeke-em changed the title io: CopyBuffer comment should be more precise io: CopyBuffer should document when buf is not used Oct 15, 2019
sandyskies added a commit to sandyskies/go that referenced this issue Oct 20, 2019
Document that if either src implements the WriteTo interface
or if dst implements the ReaderFrom interface, then
buf will not be used.

Fixes golang#32276
sandyskies added a commit to sandyskies/go that referenced this issue Oct 21, 2019
Document that if either src implements the WriteTo interface
or if dst implements the ReaderFrom interface, then
buf will not be used.

Fixes golang#32276
@gopherbot
Copy link

Change https://golang.org/cl/179137 mentions this issue: io: make CopyBuffer docs state when buf is not used

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
3 participants