GoCompilerInternals

//go:embed: From Comment to Binary - Linker Internals, Tradeoffs and Production Patterns

This talk follows a single //go:embed directive through go build, the compiler and the linker, then looks at what embedding costs you and how to test it.

GopherCon Africa

Oct 30, 2026

Everyone loves //go:embed: two lines and your templates, migrations and web assets ship inside a single binary. But how does a comment end up as bytes in your program? This talk follows one directive through every stage of go build: package discovery, the lexer, pattern resolution and embedcfg, the parser’s syntax tree, the compiler’s static data and finally the linker. It then covers what embedding costs you, from leaked secrets with the all: prefix to rebuilding for every change, and how to test embedded file systems with os.DirFS, fs.FS and testing/fstest.

Sources & links