Is there a cleaner way of getting the number of bytes written by text/template.Execute, other than writing to a temporary buffer? Here's my current code, given an already-parsed template
tmpl and a destination
io.Writer w.
var b bytes.Buffer
tmpl.Execute(&b, data)
n, err = w.Write(b.Bytes())
... where n is the number I am looking for. The above is straightforward enough, but it's two writes instead of one. It also takes more memory, I assume. I'd prefer to execute the template against w directly. (Is there a role for bufio, perhaps?) Thanks.