I am working in Go, and right now I need to print at least 20 options inside a select, so I need to use some kind of loop that goes from 0 to 20 (to get an index).
How can I use a for loop inside a Go template?
I need to generate the sequence of numbers inside the template. I don't have any array to iterate.
EDIT: I need to get something like this:
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
So, I need to do in the code something like:
<select>
{{for i := 1; i < 5; i++}}
<option value="{{i}}">{{i}}</option>
{{end}}
</select>
But, this doesn't work.