I\'m trying to write a string looking like this using go\'s template system: (p1, p2, p3), where p1, p2, ... comes from an array in the program. My problem is how to place t
See this example from the go-nuts mailing list. One key to this trick is that a template if
is different than a Go language if
. A template can test for a value of zero, unlike the Go language that requires a boolean. The magic is then {{if $index}},{{end}}
where $index needs no declaration other than its appearance in the assignment.