For example:
func main() {
t := template.Must(template.New("abc").Parse("{{ range . }}{{ . }}, {{ end }}."))
a := []string{"Alice", "Bob", "Cherry", "Dark"}
t.Execute(os.Stdout, a)
}
The output is:
Alice, Bob, Cherry, Dark, .
But I want to get:
Alice, Bob, Cherry, Dark.
Notice after the last element "Dark" expect dot, not comma.
I know I can write a function to do this, but is there a easy way to do it in template?