Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
text/template: Permit user of Reader objects in templates #37092
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:
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?
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.