How to iterate over map keys in template?

7,518 views
Skip to first unread message

John Barham

unread,
Jun 2, 2012, 1:49:09 AM6/2/12
to golang-nuts
The template action {{range m}} iterates over a map m's values, but is
it possible to iterate over its key?

John

David Symonds

unread,
Jun 2, 2012, 2:01:11 AM6/2/12
to John Barham, golang-nuts
On Sat, Jun 2, 2012 at 3:49 PM, John Barham <jba...@gmail.com> wrote:

> The template action {{range m}} iterates over a map m's values, but is
> it possible to iterate over its key?

Sure. Look at http://golang.org/pkg/text/template/, under "Variables".


Dave.
Reply all
Reply to author
Forward
0 new messages