Say I have go body text / template:
{{.var}} is another {{.var2}}
I want to get an array of variable names used in a template to skip execution if they are not available in the data that I pass for execution, is this possible somehow?
Since my data is not a structure, but a map, executing .var will always return something: if it does not exist, it will return an empty string when I would hope to get an error while executing the template.
So, for the example above, I would like to get:
[var var2]
source
share