How do you hot deploy your golang templates?

agolangf · · 601 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>especially some templates are nested.</p> <hr/>**评论:**<br/><br/>captncraig: <pre><p>I wrote <a href="https://github.com/captncraig/temple">https://github.com/captncraig/temple</a> to deal with my pain in this area. It works for me.</p> <p>I put all templates in a /templates folder. At dev, I set an environment variable to use dev mode and all templates are loaded anytime I render anything. </p> <p>In prod, I generate code that embeds the templates in a map[string]string and they all get compiled once on app start. This feeds my obsession with deploying all apps as single binaries. Most other bindata solutions don&#39;t work well with templates.</p></pre>alasijia: <pre><p>cool idea!</p></pre>i_regret_most_of_it: <pre><p>If <code>development</code> flag var is set, reload templates (via globbing) every request. It&#39;s fast anyway, have deployed production services that do this because lazy.</p> <p>I suppose you could add something like <code>USR1</code> signal to reload the templates, but I never felt the need.</p></pre>alasijia: <pre><p>Could you explain it more detailedly? It is very appreciated if you can post a piece of code here.</p></pre>

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

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