![]() ![]() ![]() Unfortunately, since fs.FS is read-only, I'm sitting here thinking up complicated ways that I could support fs.FS and somehow still support actually writing and mutating files on disk. It just wants to take in an fs.FS and a list of paths.Īdditionally, to make this package more testable, using fs.FS would make it trivial to write tests without having to actually read and write files on disk. This codec package doesn't want to care about supporting all the different places that the underlying files could be stored. In point of fact, this is intended to be an archival format that distributes the contents of a single archive over a configurable number of actual files, and these files might be distributed geographically across different regions for redundancy. I would like to implement it in terms of fs.FS, which would make it so the library doesn't have to care whether these files actually exist on the local filesystem, in memory, or stored somewhere else. I'm currently experimenting with writing a file format encoding/decoding/mutating package that is intended to work with files that aren't guaranteed to easily fit in memory. What I would love to see from a community member's perspective is the following: I don't feel qualified to define an interface, I know people have thought about this much harder than I have. Of course, there are many other file system libraries that came before io/fs that define writable interfaces like afero and billy. For many of these implementations, you can imagine a useful writable implementation. : defines file.Write, file.Seek and file.Close.Ī quick search on Github will yield more community libraries.We've already seen started to see this pop up in the community around io/fs to address the problem in user-land: Write files to cloud storages like Google Cloud Storage or Amazon S3.Useful for file bundlers and databases that work in-memory and flush to the operating system's filesystem at the end. A virtual filesystem that you can write to over time.I'll list of few use-cases that I've come across since Go 1.16, but I'm sure the community has many more: Writable)īut it suffers from the same issues that the readable filesystem interface aimed to solve: standardizing the interface across the ecosystem. We can't rely on vfs.Writable being implemented across community packages. ![]()
0 Comments
Leave a Reply. |