Similar to afero, but with composable interfaces more akin to io/fs.
Also an anagram for "fish".
This was not intentional.
import (
"os"
"io/fs"
"github.com/unstoppablemango/ihfs"
"github.com/unstoppablemango/ihfs/osfs"
"github.com/unstoppablemango/ihfs/try"
)
// Built around [io/fs]
var fs fs.FS = osfs.New()
// Regular type checks
if mkdir, ok := fs.(ihfs.MkdirFS); ok {
_ = mkdir.Mkdir("foo", os.ModeDir)
}
// The [try] package
_, err := try.WriteFile(fs, "foo/bar.txt", []byte("❤️"), os.ModePerm)
// Walking with [iter.Seq]
seq, err := ihfs.Catch(ihfs.Iter(fs, "."))
for path, dirEntry := range seq {
// .
// ./foo
// ./foo/bar.txt
}Much of the implementation is adapted from afero, specifically the corfs, cowfs, and union packages.
Imitation is the sincerest form of flattery
- Charles Caleb Colton (often misattributed to Oscar Wilde)