Re: [go-nuts] Non-alphanumerics in template field names?

2020-08-01 Thread roger peppe
You could use the "index" built-in function instead of the dot operator:

{{index . "foo:bar"}}

On Fri, 31 Jul 2020, 17:16 Bob DuCharme,  wrote:

> I have seen that a map key name of "foo:bar" works just fine... unless I
> reference it in a template. {{.foo:bar}} gives me a segmentation violation
> at runtime, but works fine if there was no colon in the map key name. I
> have tried various ways to escape the colon or quote the field name (e.g.
> {{."foo:bar"}}, {{.foo%3Abar}} ) with no luck.
>
> Does anyone know a way to allow non-alphanumeric characters (besides the
> underscore, which I know works) in names that get referenced in templates?
>
> Thanks,
>
> Bob
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/ec64bc07-52a8-429d-bf13-7853da959925n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAJhgaciaZhVn4fYmm8GGr-56qA0t_HS4iSpAXEcBPR%3DSvo4tgQ%40mail.gmail.com.


[go-nuts] Non-alphanumerics in template field names?

2020-07-31 Thread Bob DuCharme
I have seen that a map key name of "foo:bar" works just fine... unless I 
reference it in a template. {{.foo:bar}} gives me a segmentation violation 
at runtime, but works fine if there was no colon in the map key name. I 
have tried various ways to escape the colon or quote the field name (e.g. 
{{."foo:bar"}}, {{.foo%3Abar}} ) with no luck. 

Does anyone know a way to allow non-alphanumeric characters (besides the 
underscore, which I know works) in names that get referenced in templates? 

Thanks,

Bob

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ec64bc07-52a8-429d-bf13-7853da959925n%40googlegroups.com.