Documentation ¶
Overview ¶
Package sectionedfs implements an afero.Fs filesystem in which immediate subdirectories are named by strings mapped to other afero.Fs filesystems. You can combine disparate directories from multiple filesystems into what is accessed as a single directory.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fs ¶
Fs implements the afero.Fs interface for a group of named afero.Fs's. Each sub-Fs is accessed via the first element of the paths given to Fs
Example ¶
package main import ( "fmt" "io/ioutil" "github.com/spf13/afero" "gitlab.com/tbhartman/sectionedfs" ) func main() { a := afero.NewMemMapFs() b := afero.NewMemMapFs() parentFs := sectionedfs.New() parentFs.RegisterSection("a", a) parentFs.RegisterSection("b", b) fs := parentFs.(afero.Fs) fs.MkdirAll("a/dir_under_a", 0700) fs.MkdirAll("b/dir_under_b", 0700) fa, _ := fs.Create("a/dir_under_a/file_in_a") fa.WriteString("sample text\n") fa.Close() fileViaChild, _ := a.Open("dir_under_a/file_in_a") contents, _ := ioutil.ReadAll(fileViaChild) fmt.Print(string(contents)) }
Output: sample text
Click to show internal directories.
Click to hide internal directories.