Embed static assets in binary with Go Generate
Jantcu
This video shows how to embed static file information in a binary using the "go generate" command. This allows you to reference files and information that might not necessarily be available on the end user's computer.
We use go generate with Plenti to embed JavaScript, JSON, and other static assets:
Calling the generator: https://github.com/plentico/plenti/blob/master/main.go
Defining the generator: https://github.com/plentico/plenti/blob/master/generators/main.go
Example generated code: https://github.com/plentico/plenti/blob/master/generated/ejected.go
Proposal to allow embedding static assets (files) into binaries: https://github.com/golang/go/issues/35950
Go generate documentation: https://blog.golang.org/generate ... https://www.youtube.com/watch?v=uH0SGxA5UJM
57446251 Bytes