Using a map as a dataset for template.Execute()

7 views
Skip to first unread message

murodese

unread,
Nov 18, 2009, 10:14:56 AM11/18/09
to golang-nuts
Is this even possible? Looks like you can only use single strings or
structs, which seems pretty silly.

Rob 'Commander' Pike

unread,
Nov 18, 2009, 11:33:29 AM11/18/09
to murodese, golang-nuts

On Nov 18, 2009, at 7:14 AM, murodese wrote:

> Is this even possible? Looks like you can only use single strings or
> structs, which seems pretty silly.

Being able to use a map seems reasonable. Please file a bug.

-rob

Russ Cox

unread,
Nov 18, 2009, 11:52:03 AM11/18/09
to murodese, golang-nuts
On Wed, Nov 18, 2009 at 07:14, murodese <raw...@gmail.com> wrote:
> Is this even possible? Looks like you can only use single strings or
> structs, which seems pretty silly.

You should be able to use slices too.

The reason we've left maps out so far is that the iteration
order on maps is not specified, so most of the time it makes
sense to prepare a slice with the map elements in the desired
order instead of accepting whatever order the map feels like.

Russ

murodese

unread,
Nov 18, 2009, 11:58:03 AM11/18/09
to golang-nuts
Great, thanks for the reply guys.

On Nov 19, 12:52 am, Russ Cox <r...@golang.org> wrote:
Reply all
Reply to author
Forward
0 new messages