embed

The Go package and //go:embed comment that build files such as templates or static assets into the binary at compile time.

In more detail

A variable marked with //go:embed receives the file contents when you build, so the program does not need those files next to it at run time. This keeps a static binary truly self-contained, which suits scratch images.

Example

//go:embed index.html
var page string

Related terms

Taught in

References