MapFS
fsys := fstest.MapFS{
"hello.txt": {Data: []byte("hi")},
"dir/note.md": {Data: []byte("# note")},
}
data, _ := fs.ReadFile(fsys, "hello.txt")
testing/fstestIn-memory fs.FS for tests, plus TestFS to validate custom fs.FS implementations.
fsys := fstest.MapFS{
"hello.txt": {Data: []byte("hi")},
"dir/note.md": {Data: []byte("# note")},
}
data, _ := fs.ReadFile(fsys, "hello.txt")
if err := fstest.TestFS(myFS, "a.txt", "dir/b.txt"); err != nil {
t.Fatal(err)
}