On Tue, Feb 20, 2018 at 5:23 PM, Alex Dvoretskiy
<advoretski...@gmail.com> wrote:
> Hello golang-nuts,
>
> https://play.golang.org/p/Lib9EfWcsjG
>
> If you run this code it works fine. But if you remove one "Actor" key -
> template stops executing: "template: movielist:10:14: executing "movielist"
> at <.Actor.Name>: can't evaluate field Name in type *main.Actor"
>
> Modified version: https://play.golang.org/p/K2DS99iZmFl
>
> `{"Movies":
> [
> {
> "Title": "Cool Hand Luke",
> "Actor": {"Name": "Paul Newman"}
> },
>     {
> "Title": "Bullitt",
> "Actor": {"Name":"Steve McQueen"}
>     },
>     {
> "Title": "Casablanca"
>     }
> ]
> }`
>
> Can you advice how should I change the template to make it work?

  <td>{{if .Actor}}{{.Actor.Name}}{{end}}</td>


>
> Thanks
> Alex
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to