Use the //go:embed directive to embed files directly into your binary at compile time. Place the directive above a variable declaration, specifying the file path pattern relative to the source file.
package main
import "embed"
//go:embed templates/*.html
var TemplateFS embed.FS
func main() {
// TemplateFS now contains all .html files in the templates directory
}
This creates a read-only filesystem (embed.FS) that you can use with html/template or io/fs to read files without needing external assets.