I am trying to achieve a very simple thing in a Go template and failing!
The range
action allows me to iterate through an array along with its zero-based index, as so:
{{range $index, $element := .Pages}}
Number: {{$index}}, Text: {{element}}
{{end}}
However, I am trying to output indices that start counting from 1. My first attempt failed:
Number: {{$index + 1}}
This throws an illegal number syntax: "+"
error.
I looked into the go-lang official documentation and did not find anything particular regarding the arithmetic operation inside the template.
What am I missing?