title: golang template.Execute and struct embedding
body: <p>I have a little website project written go where you can store links, and I ran into a problem :</p>
  
  <p>The website has many different pages which show different information so you need to pass template.Execute a different kind of a struct. But every page also needs info like username and tags, which are displayed in sidebar. I tried to make something like this instead of just making completely new struct type for each page.</p>
  
  <p><a href="http://play.golang.org/p/VNfD6i8p_N" rel="nofollow">http://play.golang.org/p/VNfD6i8p_N</a></p>
  
  <pre><code>type Page interface {
      Name() string
  }
  
  type GeneralPage struct {
      PageName string
  }
  
  func (s GeneralPage) Name() string {
      return s.PageName
  }
  
  type PageRoot struct {
      Page
      Tags       []string
      IsLoggedIn bool
      Username   string
  }
  
  type ListPage struct {
      Page
      Links     []Link
      IsTagPage bool
      Tag       string
  }
  
  type GalleryPage struct {
      Page
      Image    Link
      Next     int
      Previous int
  }
  </code></pre>
  
  <p>But I get an error when I execute the template: <code>"fp.tmpl" at &lt;.Links&gt;: can't evaluate field Links in type main.Page</code></p>
  
  <p>The part of the template where the error occurs:</p>
  
  <pre><code>  {{with .Page}}
    {{range .Links}}
    &lt;tr&gt;
      &lt;td&gt;{{if .IsImage}}&lt;img src="{{.Url}}" /&gt;{{end}}&lt;/td&gt;
      &lt;td&gt;{{.Name}}&lt;/td&gt;
      &lt;td&gt;{{.Url}}&lt;/td&gt;
      &lt;td&gt;{{.TagsString}}&lt;/td&gt;
    &lt;/tr&gt;
    {{end}}
    {{end}}
  </code></pre>
  
  <p>And <code>{{.Name}}</code> doesn't work. (It's the function embedded from GeneralPage)</p>