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
This will temporarily be implemented in traverse under storage package, but will eventually be moved to replace the existing one in extendio.
Will require the use of an in memory filesystem; use the one already defined in extendio.
Actually, we should prefer to use std library dependencies wherever possible and it turns out that there is already an in memory file system defined in fstest.MapFS implemented as a map from file-path to fstest.MapFile.
We may not even need our own storage package, rather, we wriite our own file-system dependent code to rely on io.FS. Also, we can use testing/fstest to test file system dependent code.
traverse should not make explicit calls to the native fs, rather it should only ever depend on fsys.FS, just like fs.WalkDir.
Some key points to note
you can create a custom filesystem FS, from a root path by:
Actually, it seems no code is required to fix this. All we need to do is just depend on fsys.FS when we navigate the file system and use fstest.MapFS for unit-testing.
It should be noted that there is an fs.FS that was released after io.FS and provides additionality functionlity, such as the ability to combine multiple file systems using fs.Merge. Most of the time traverse will create a single file sytem rooted at the path requested. However, there will come a point where access to another part of the file system, not under root is required, eg when save is invoked; at this point, we create a new fs merged with the root fs.
rootFS, _:=os.Open("/path/to/root")
deferrootFS.Close()
anotherFS, _:=os.Open("/another/path")
deferanotherFS.Close()
combinedFS:= fs.Union{
Filesystems: []fs.FS{rootFS, anotherFS},
}
// Use combinedFS for operations across both root paths
This will temporarily be implemented in traverse under storage package, but will eventually be moved to replace the existing one in extendio.
Will require the use of an in memory filesystem; use the one already defined in extendio.
Actually, we should prefer to use std library dependencies wherever possible and it turns out that there is already an in memory file system defined in fstest.MapFS implemented as a map from file-path to fstest.MapFile.
We may not even need our own storage package, rather, we wriite our own file-system dependent code to rely on io.FS. Also, we can use testing/fstest to test file system dependent code.
traverse should not make explicit calls to the native fs, rather it should only ever depend on fsys.FS, just like fs.WalkDir.
Some key points to note
See fs for more details (in particular, lookk at the test cases; there are examples of how to use the in memory fs)
Also, this is an interesting reference article that discusses the fs.FS interface.
The text was updated successfully, but these errors were encountered: