We break down how
os.DirFS turns a directory into an implementation of the
fs.FS interface, why this kind of FS uses “FS paths” internally (always with a slash
/), how to read files correctly via
fs.ReadFile, build names via
path.Join (not
filepath.Join), and how to correctly recognize “file not found” using
errors.Is and
fs.ErrNotExist. At the end:
DirFS limitations, security nuances, and common mistakes.