mergefs

package module
v0.0.0-...-07f27d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 8

README

mergefs

MergeFS allows to merge different filesystems into a single one, trying to keep the ancillary interfaces (GlobFS, FileReaderFS) to avoid side effects when calling such methods in the merged FS. Standard methods for reading a file or searching globs might take different paths depending on whether the filesystem implements one ancillary interface or not ending up in slightly different results. By keeping the public API of the filesystems we aim to avoid such differences.

Important: Clashing paths among merging FS have been skipped on purpose to keep this library simple by respecting the ordering of the FS being merged, meaning that when looking for a file, the search ends as soon as the file is found.

Getting started

fsA := fstest.MapFS{"a.txt": &fstest.MapFile{Data: []byte("test a")}}
fsB := fstest.MapFS{"b.txt": &fstest.MapFile{Data: []byte("text b")}}

mfs := mergefs.Merge(fsA, fsB)
if _, err := mfs.Open("a.txt"); err != nil {
  // ...
}

MergeFS is highy inspired by https://github.com/laher/mergefs and https://github.com/yalue/merged_fs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Merge

func Merge(filesystems ...fs.FS) fs.FS

Merge filesystems

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL