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: Permit user of Reader objects in templates #37092

Open
zaddok opened this issue Feb 6, 2020 · 3 comments
Open

text/template: Permit user of Reader objects in templates #37092

zaddok opened this issue Feb 6, 2020 · 3 comments
Labels
FeatureRequest NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zaddok
Copy link

zaddok commented Feb 6, 2020

In the case where we need to use a reader to avoid buffering large amounts of data in memory, there appears no way to use this reader in a go template.

This issue was raised before here:

#25160

In summary, it was dismissed on the basis of "most people don't need this". I would like to contest this. There are a lot of things "most people don't need" but what if the reason for the need is an important edge case (i.e. applications processing large data sets). Surely there are some people processing applications that operate over large data sets?

@ianlancetaylor
Copy link
Contributor

I'm not sure what you are asking for. Issue #25160 ended by suggesting opening a proposal for the change. Do you want to do that? Indicate exactly what you think should be added to the text/template API. Thanks.

@toothrot toothrot changed the title Permit user of Reader objects in templates text/template: Permit user of Reader objects in templates Feb 6, 2020
@toothrot
Copy link
Contributor

toothrot commented Feb 6, 2020

@zaddok See also the discussion of the proposal at #29165. Unless some of the concerns there are addressed in this issue, I don't understand what change should be made to Go.

@zaddok
Copy link
Author

zaddok commented Feb 7, 2020

At a high level, it would be good to not have to (for example) load a 10mb array into memory so that a template can range over it to build a html or text document (that may also end up being 10mb). It would be desirable if a template could range over a Reader object that returns elements one by one.

I am not so interested in prescribing a particular implementation, just trying to work out how to handle requests that trigger high memory usage in my app server.

@dmitshur dmitshur added this to the Backlog milestone Feb 14, 2020
@dmitshur dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. FeatureRequest labels Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest 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

4 participants