This program outputs simply
1,4,2,
but I would like to print
1,4,2.
As you can see the comma is printed after each items of an array.
package main
import "os"
import "text/template"
func main() {
params := map[string]interface{}{
"items": [3]int{1, 4, 2},
}
tpl := "{{range $i, $el := .items}}{{$el}},{{end}}"
lister, _ := template.New("foo").Parse(tpl)
lister.Execute(os.Stdout, params)
}
Is there a way to change {{range $i, $el := .items}}{{$el}},{{end}}
and be sure that last item will print "." instead of ","