Skip to content

feat(iofs): add io/fs.FS adapter for vfs.Location - #409

Open
funkyshu wants to merge 1 commit into
mainfrom
feat/iofs-adapter
Open

funkyshu wants to merge 1 commit into
mainfrom
feat/iofs-adapter

Conversation

@funkyshu

@funkyshu funkyshu commented Nov 6, 2026

Copy link
Copy Markdown
Member

Summary

Adds an iofs package whose New(loc) presents any vfs.Location as a read-only io/fs.FS that also implements fs.StatFS, fs.ReadDirFS, fs.ReadFileFS and fs.SubFS. Works with http.FileServerFS, template.ParseFS, fs.WalkDir and fs.Glob. Additive, no change to any v7 interface.

  • Names are resolved by listing the parent directory with list.Entries, so behavior is identical on every backend. A name that is both a file and a directory (object stores) is a file, and ReadDir lists it once.
  • ReadDir streams entries with their listed size and modification time.
  • Errors are *fs.PathError values matching fs.ErrNotExist, fs.ErrInvalid and so on.
  • Documented limits: symlinks are not followed, and a missing root looks empty.

Testing

Closes #408

Add the iofs package, whose New(loc) presents any vfs.Location as a
read-only fs.FS that also implements fs.StatFS, fs.ReadDirFS,
fs.ReadFileFS and fs.SubFS.

Names are resolved by listing the parent directory through list.Entries,
so behavior is the same on every backend. A name that is both a file and
a directory is a file. ReadDir streams entries with their listed
metadata.

The testcontainers module runs fstest.TestFS on mem, os, sftp, azure and
s3. gs and ftp are skipped until their Seek defects (#406, #407) are
fixed.

Refs #408
@c2fo-cibot c2fo-cibot Bot added the size/XXL Denotes a PR that changes 1000+ lines label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an io/fs.FS adapter for vfs.Location

1 participant