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?
评论:
ahacker16:
karnd01: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.
If you consider HTML templates + JS + CSS + images + i18n files + etc, is a difference of distribute a lot of files vs. a single binary.
It's also a lot easier to make self-updatable apps with something like go-update.
I personally recommend fileb0x instead go-bindata.
ZetaHunter: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 :)
ishbits:Personally I use go.rice 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.
tscs37: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.
tomByrer: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.
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.
bkeroack: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?
jiimji:Use Docker.
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.
