Is including assets (with a tool like go-bindata) an anti-pattern?

agolangf · · 506 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m developing a web application and thought it would be a good idea to use a tool like go-bindata to include the assets in the binary. Now I&#39;ve come to re-evaluate that decision: is this a good idea or am I over-complicating things? What do you think?</p> <hr/>**评论:**<br/><br/>ahacker16: <pre><p>I don&#39;t think there&#39;s much improvement if you&#39;re hosting your app yourself, but it&#39;s a huge win when you need to distribute your app for many people/companies.</p> <p>If you consider HTML templates + JS + CSS + images + i18n files + etc, is a difference of distribute a lot of files vs. a single binary.</p> <p>It&#39;s also a lot easier to make self-updatable apps with something like <a href="https://github.com/inconshreveable/go-update" rel="nofollow">go-update</a>.</p> <p>I personally recommend <a href="https://github.com/UnnoTed/fileb0x" rel="nofollow">fileb0x</a> instead go-bindata.</p></pre>karnd01: <pre><p>I agree with @ahacker16 except about hosting your application yourself; bundling also allows these assets to be served from memory instead of disk which will always be faster :)</p></pre>ZetaHunter: <pre><p>Personally I use <a href="https://github.com/GeertJohan/go.rice" rel="nofollow">go.rice</a> for all my embedding needs, it can also look at local FS so it would still allow for one to manually override templates and what not.</p></pre>ishbits: <pre><p>I love this approach. I make an app that people run on their own machines and it&#39;s convenient that it&#39;s just a single binary - no directory layout or environment vars to worry about. </p></pre>tscs37: <pre><p>I don&#39;t think it&#39;s an antipattern as long as you provide the fat binary along with either an option to override some assets with custom versions or alternatively provide a slim version that uses the filesystem.</p> <p>Using binned assets has the advantage that a deployment is much much easier and the app doesn&#39;t rely as much on the filesystem and keeps permissions simpler.</p></pre>tomByrer: <pre><p>If you care about &#39;time to glass&#39; (effectively startup time), you might want to consider NodeJS bundlers like Rollup or Webpack which will &#39;treeshake&#39; the JavaScript, removing unused code. I don&#39;t know of equivalents for GoLang?</p></pre>bkeroack: <pre><p>Use Docker.</p></pre>jiimji: <pre><p>it is. if you are writing a web app, then you should bundle in a zip before you deploy. If you are using a cli-tool and it needs specific assets, then it should bundle too, whether it is with a native package manager or not it doesn&#39;t matter. external assets shouldn&#39;t be compiled with the rest of the program.</p></pre>

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

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