Skip to content

UnstoppableMango/ihfs

Repository files navigation

I ❤️ File Systems

GitHub Actions Workflow Status GitHub branch check runs Codecov

Similar to afero, but with composable interfaces more akin to io/fs.

Also an anagram for "fish".

This was not intentional.

Usage

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
}

Attribution

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)

About

I ❤️ FileSystems!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages