You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go's new FS interface is pretty cool, I've used in quite a few projects to serve files embedded into the binary, to do overlayFS-like stuff (merge multiple directories as one) etc. fs.FS enables all of this craziness.
My proposal: instead of giving direct filesystem path like /my/path to a module, the module would take in fs.FS and you could give in os.DirFS("/my/path").
I am willing to send a PR if you are interested. I have not read through the server code to check if there are any requirements that don't have direct analogies in fs interfaces. uid/gid things in Stat() calls would be one thing not present in fs.FileInfo. Those cases would need to be type-switched on (check if stat result is a structure that actually carries uid/gid)
The text was updated successfully, but these errors were encountered:
Yeah, I think we should do this. Probably better to wait until next week, because I’m planning to do some work around extendend attributes and such. I assume that afterwards, I’ll have a much better idea of how much is covered by fs.FS, or what extra things we need :)
Aside from file paths and stat(2) results, we also need symlink target resolution.
Use-case wise, aside from serving static assets and serving the file system, it would be interesting to sketch whether to-be-served data can be generated on the fly, too, with the fs.FS interface.
Go's new FS interface is pretty cool, I've used in quite a few projects to serve files embedded into the binary, to do overlayFS-like stuff (merge multiple directories as one) etc. fs.FS enables all of this craziness.
My proposal: instead of giving direct filesystem path like
/my/path
to a module, the module would take infs.FS
and you could give inos.DirFS("/my/path")
.I am willing to send a PR if you are interested. I have not read through the server code to check if there are any requirements that don't have direct analogies in
fs
interfaces. uid/gid things inStat()
calls would be one thing not present in fs.FileInfo. Those cases would need to be type-switched on (check if stat result is a structure that actually carries uid/gid)The text was updated successfully, but these errors were encountered: