<p>Specifically, the view directory doesn't display any templates.</p>
<p>The Terminal says "panic serving 127.0.0.1:58912: runtime error: invalid memory address or nil pointer dereference" when I load something in the /view/ dir that already exists.</p>
<p><a href="http://pastebin.com/sDuYe5wy" rel="nofollow">http://pastebin.com/sDuYe5wy</a></p>
<hr/>**评论:**<br/><br/>Fwippy: <pre><p>Possibly your templates are failing to parse:</p>
<pre><code>t, _ := template.ParseFiles(tmpl + ".html")
t.Execute(w, p)
</code></pre>
<p>If <code>ParseFiles()</code> encounters an error, <code>t</code> will be <code>nil</code>. Don't ignore errors.</p></pre>Bouncingbunny13: <pre><p>I fixed it just after I posted it.
Thanks for the help though; I fixed the error handling as well.</p></pre>youmeangit: <pre><p>There's basically a guarantee that if you're posting in <a href="/r/golang" rel="nofollow">/r/golang</a> with an unknown error, you're probably ignoring an error somewhere. Everytime...</p></pre>
My server code won't display some pages. Specifically the view directory won't show templates.
polaris · · 483 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传