Re:Go 1.22 Release Notes
by jadayesnaamsi on Wednesday February 07, 2024 @05:41AM
(#39286887)
A 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/embe...
Last I checked, AdGuard Home also did this.
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.