Virtual filesystems

Files are a struct in Go, a concrete type, and there's no abstraction around them, whereas a file's information is represented by os.FileInfo, which is an interface. This is slightly inconsistent, and there have been many attempts to create a full and consistent abstraction on the filesystem, commonly referred to as a virtual filesystem.

Two of the most used packages are as follows:

Even if they are developed separately, they both do the same thing – they define an interface with all the methods of os.File, and then they define an interface that implements the function that's available in the os package, like creating, opening, and deleting files, and so on.

They offer a version based on os.File that's implemented using the standard package, but there's also a memory version that uses data structures that emulate a filesystem. This can be very useful for building a test for any package.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.20.224.107