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

go2draft-error-handling-overview: Double io.Closer calls #27750

Open
RalphCorderoy opened this issue Sep 19, 2018 · 2 comments
Open

go2draft-error-handling-overview: Double io.Closer calls #27750

RalphCorderoy opened this issue Sep 19, 2018 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@RalphCorderoy
Copy link

The examples in https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling-overview.md arrange for w.Close() to be called more than once. https://golang.org/pkg/io/#Closer says
The behavior of Close after the first call is undefined. Specific implementations may document their own behavior.

The text before the code, and the problem:

On the other hand, the equivalent actual Go code today would be
Defers w.Close() and then calls w.Close().

For example, the corrected code above shortens to
checks w.Close() but also does that in an above handler.

It's OK for the double-Close to be one of the faults with the 'before', but it would be nice if the improved 'after' version didn't also do it. The more robust version with more helpful errors would be one in between doesn't.

CC: @rsc

@bcmills
Copy link
Contributor

bcmills commented Sep 19, 2018

See also #25408 (OnceCloser).

@bcmills
Copy link
Contributor

bcmills commented Sep 19, 2018

CC: @mpvl

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 19, 2018
@bcmills bcmills added this to the Unreleased milestone Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants