package main import ( "io" "log" "strings" "git.codemonkeysoftware.net/b/sbsqlitessgcms/fs" ) type File string func (f File) Get() io.Reader { return strings.NewReader(string(f)) } type Dir map[string]interface{} func (d Dir) Get() []fs.DirEntry { var entries []fs.DirEntry for name, child := range d { entry := fs.DirEntry{ Name: name, } switch t := child.(type) { case File: entry.FS = fs.File{Contents: t} case Dir: entry.FS = fs.Dir{Entries: t} default: panic("aw hell naw") } entries = append(entries, entry) } return entries } func main() { dir := fs.Dir{ Entries: Dir{ "a": File("apple"), "b": File("bootilicious"), "c": File("curveball"), "d": Dir{ "e": File("ectoplasm"), "f": File("^&*("), "g": File("grrrl power"), "h": File("hellabyte"), }, }, } err := fs.Realize("./stuff", dir) if err != nil { log.Fatal(err) } }