I need to use a map in template, however, the syntax is not correct
<tr>
<td>India</td>
<td>{{$val.Agent.Imei}}</td>
<td>{{$val.Jid}}</td>
<td>{{.LoginTimeMap[$val.Jid]}}
</tr>
it saids the [] in {{.LoginTimeMap[$val.Jid]}} is unexpected bad character U+005B '[' in command
Please Help
In templates, use index
instead of []
.
http://golang.org/pkg/text/template/#hdr-Functions
index
Returns the result of indexing its first argument by the following arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each indexed item must be a map, slice, or array.