Rendering template in golang
<p>I am using the echo framework in Go to create a web app. I have a directory called <code>templates</code> inside which I have two directories <code>layouts</code> and <code>users</code>. The directory tree is as follows:</p>

<pre><code>layouts
|--------default.tmpl
|--------footer.tmpl
|--------header.tmpl
|--------sidebar.tmpl

users
|--------index.tmpl
</code></pre>

<p>The code for header, footer, and sidebar are similar with:</p>

<pre><code>{{define "header"}}
&lt;!-- some html here --&gt;
{{ end }} 
....
</code></pre>

<p><code>default.tmpl</code> is as follows:</p>

<pre><code>{{ define "default" }}
{{ template "header" }}

{{ template "sidebar" }}

&lt;div class="content-wrapper"&gt;
    &lt;div class="container-fluid"&gt;

        &lt;div class="row"&gt;
            &lt;div class="col-md-12"&gt;
                &lt;h2 class="page-title"&gt;Dashboard&lt;/h2&gt;
                {{ template "content" .}}
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

{{ template "footer" }}
{{ end }}
</code></pre>

<p>And <code>users\index.tmpl</code></p>

<pre><code>{{define "index"}}
    {{template "default"}}
{{end}}

{{define "content"}}
&lt;p&gt;Hello world&lt;/p&gt;
{{end}}
</code></pre>

<p>Now, I parse the files using</p>

<pre><code>t := &amp;Template{}
t.templates = template.Must(template.ParseGlob("views/layouts/*"))
t.templates = template.Must(template.ParseGlob("views/user/*"))
</code></pre>

<p>And try to render it </p>

<pre><code>func User(c echo.Context) error {
    return c.Render(http.StatusOK, "index", nil)
}
</code></pre>

<p>But I only get an internal server error. I don't know how to debug the templates either. The code works if the <code>users\index.tmpl</code> does not contain other template tags inside it. But when I try to include the main template in it, the error returns. What am I doing wrong here?</p>