4 ms·
One example that comes to mind is building a single-binary full-stack application. You can use whatever frontend framework you want, and just embed the html/cs
by bheadmaster 3y ago
One example that comes to mind is building a single-binary full-stack application.
You can use whatever frontend framework you want, and just embed the html/css/js/asset files inside the binary with go:embed. In case of dynamic set of files, you can also write a Go utility to generate the embeddings with go:generate.
In addition to the ease of distribution (no more assets/ directory - just a single binary executable!), it also increases speed of the application, as it no longer has to perform file system reads in order to serve a webpage.
- jadayesnaamsi 3y agoA good example of a Go project using embed to pack its html/css/js assets in a single binary is PocketBase: https://github.com/pocketbase/pocketbase/blob/master/ui/embed.go https://github.com/pocketbase/pocketbase/blob/master/ui/embe...
- heywire 3y agoLast I checked, AdGuard Home also did this. https://github.com/AdguardTeam/AdGuardHome https://github.com/AdguardTeam/AdGuardHome