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

text/template: (also html/template?) document Execute can write to writer before returning an error #7445

Closed
sidnei opened this issue Mar 3, 2014 · 7 comments

Comments

@sidnei
Copy link

sidnei commented Mar 3, 2014

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. create a template with multiple sub-templates (if i got the terminology right)
2. .Execute() it with a writer

What is the expected output?
If .Execute() returns an error, the expectation is that no output is written.

What do you see instead?
Depending on how the template is constructed, .Execute() may cause some data to be
written before the error is returned. 

It should be documented that if you require no output to be written in the case of an
error, then you should necessarily write out to a temporary buffer and check the error
first, and then copy the buffer to it's final destination.

Please provide any additional information below.
http://play.golang.org/p/1JYAcgouZd
@bradfitz
Copy link
Contributor

bradfitz commented Mar 3, 2014

Comment 1:

Pretty sure this is WAI but assigning to Rob to decide.

Owner changed to @robpike.

@robpike
Copy link
Contributor

robpike commented Mar 3, 2014

Comment 2:

Yes, the code is working as intended - otherwise the package could require an unbounded
amount of buffering - but perhaps the documentation should say something about the topic.

Labels changed: added release-go1.3maybe, repo-main.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented May 11, 2014

Comment 3:

Labels changed: added documentation.

@robpike
Copy link
Contributor

robpike commented May 19, 2014

Comment 4:

Labels changed: added release-go1.4maybe, removed release-go1.3maybe.

@robpike
Copy link
Contributor

robpike commented May 19, 2014

Comment 5:

Labels changed: added release-go1.3, removed release-go1.4maybe.

@gopherbot
Copy link

Comment 6:

CL https://golang.org/cl/94640043 mentions this issue.

@robpike
Copy link
Contributor

robpike commented May 19, 2014

Comment 7:

This issue was closed by revision 431b96b.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned robpike Jun 23, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants