My server code won't display some pages. Specifically the view directory won't show templates.

polaris · · 483 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Specifically, the view directory doesn&#39;t display any templates.</p> <p>The Terminal says &#34;panic serving 127.0.0.1:58912: runtime error: invalid memory address or nil pointer dereference&#34; 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 + &#34;.html&#34;) t.Execute(w, p) </code></pre> <p>If <code>ParseFiles()</code> encounters an error, <code>t</code> will be <code>nil</code>. Don&#39;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&#39;s basically a guarantee that if you&#39;re posting in <a href="/r/golang" rel="nofollow">/r/golang</a> with an unknown error, you&#39;re probably ignoring an error somewhere. Everytime...</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

483 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传