Lesson 42 of 60
GoEmbedding Files – `embed` Package (Go 1.16+)
15 minutes
Course progress70%
Compile‑time Assets
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
embed lets you embed static files directly into the binary.
import "embed"
//go:embed templates/*.html
var tmplFS embed.FS
func {
files, _ := tmplFS.ReadDir()
_, f := files { fmt.Println(f.Name()) }
}