Explainers · Short
Go embed: one binary in prod, live files in dev
- Published
- Duration
- Language
- English
Transcript
Text of the video's narration.
embed is easy in prod. Dev is where it hurts. go colon embed bakes your files into the binary at build time. Great for shipping. But in dev, every CSS tweak means a rebuild. Fix: program against io/fs.FS, not embed.FS. Prod file, tagged not dev, returns the embed.
Dev file returns os.DirFS. Same FileServer, same ParseFS. Run with dash tags dev, edit, refresh. No rebuild, no coffee break. Just remember: DirFS follows your working directory. Embed for the ship. Disk for the loop.
Sources
- embed pkg.go.dev
- io/fs pkg.go.dev
- Go 1.16 go.dev
- Brandur, go:embed in prod / disk in development brandur.org
- Go gopher by Renée French, CC BY 4.0 go.dev
Credits and notes
- Visuals and narration generated with AI tools.



