<p>I'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'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't think there's much improvement if you're hosting your app yourself, but it'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'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's convenient that it's just a single binary - no directory layout or environment vars to worry about. </p></pre>tscs37: <pre><p>I don't think it'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't rely as much on the filesystem and keeps permissions simpler.</p></pre>tomByrer: <pre><p>If you care about 'time to glass' (effectively startup time), you might want to consider NodeJS bundlers like Rollup or Webpack which will 'treeshake' the JavaScript, removing unused code. I don'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't matter. external assets shouldn't be compiled with the rest of the program.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传