I am starting to use go for serving dynamic html content, parsing templates, replace variables, etc. so far all good, I found that I could create a single binary and deploy a single file including all the static files by using packages like go-bindata.
But when it comes to performance what are the best practices to follow?
If I am right, having a single binary with all the static content embedded will result in a bigger file in size.
Having a binary that needs/depends to parse the templates (*.tpl)
only at at startup maybe smaller in size, but will need to be shipped with all the static content.
If space is the only difference, having a single binary looks like the more comfortable way to go for some cases, but not been an expert on the topic, I would like to know some best practices to follow keeping an eye on performance.
I you add something like
var templates = template.Must(template.ParseGlob("templates/*.html"))
in global scope, then they are parsed only on startup.
If you upload and run your app on some server, then probably having separate files is more convenient because then you can use rsync to avoid uploading file which didn't change since last upload.
Putting everything to one file can make things easier if you want to distribute only one executable for download.