Skip to content

io/fs: compose multiple FS into one #75135

@icholy

Description

@icholy

There's no way to combine multiple fs.FS values into a single tree. I wanted to create a zip archive that includes files from more than one fs.FS, but zip.Writer.AddFS only takes one fs.FS and doesn't allow specifying a prefix. fs.Sub lets you carve out part of a tree, but there’s no complementary way to merge multiple trees. This feels like a missing piece in io/fs.

An example of what an API could look like (inspired by https://github.com/lestrrat-go/multifs):

var vfs fs.Overlay

vfs.Mount("a", fs1)
vfs.Mount("b", fs2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions