I have code like this:
package main
import (
"text/template"
"os"
)
func main() {
type Map map[string]string
m := Map {
"a": "b",
"c": "d",
}
const temp = `{{range $key, $value := $}}key:{{$key}} value:{{$value}},{{end}}`
t := template.Must(template.New("example").Parse(temp))
t.Execute(os.Stdout, m)
}
it will output :
key:a value:b,key:c value:d,
but I want something like this:
key:a value:b,key:c value:d
I don't need the last comma, how to remove it. I found a solution for looping an array here: https://groups.google.com/d/msg/golang-nuts/XBScetK-guk/Bh7ZFz6R3wQJ , but I can't get index for a map.