Last Updated: May 22, 2026
Before Go 1.16, packages that read files used os.Open directly. That worked, but it tied the code to a real disk. Tests had to create temp directories, code that needed embedded assets had to use a separate API, and there was no clean way to plug in an in-memory filesystem for fast tests or a virtual filesystem for a tool. The io/fs package, introduced in Go 1.16, fixed this by turning "a filesystem" into a small interface that any source of files can satisfy: a real directory on disk, an embed.FS of compiled-in assets, a fstest.MapFS of in-memory test data, a zip archive, or anything else.