func (fs *FakeFs) WriteFile(filename string, data []byte, perm os.FileMode) error {
	return fs.a.WriteFile(filename, data, perm)
}
WriteFile via afero.WriteFile
package filesystem
import (
	"fmt"
	"os"
	"path/filepath"
	"time"
	"github.com/spf13/afero"
)
type FakeFs struct {
	a afero.Afero
}
func NewFakeFs(fakeFsRoot string) (Filesystem, func(), error) {
	_, err := os.Stat(fakeFsRoot)
	if err == nil {
		err = os.RemoveAll(fakeFsRoot)
		if err != nil {
			return nil, nil, fmt.Errorf("failed to cleanup fake root dir %s. %s", fakeFsRoot, err)
		}
	} else if !os.IsNotExist(err) {
		return nil, nil, fmt.Errorf("failed to lstat fake root dir %s. %s", fakeFsRoot, err)
	}
	if err = os.MkdirAll(fakeFsRoot, os.FileMode(0755)); err != nil {
		return nil, nil, fmt.Errorf("failed to create fake root dir: %s. %s", fakeFsRoot, err)
	}
	return &FakeFs{a: afero.Afero{Fs: afero.NewBasePathFs(afero.NewOsFs(), fakeFsRoot)}},
		func() {
			os.RemoveAll(fakeFsRoot)
		},
		nil
}
func (fs *FakeFs) Stat(name string) (os.FileInfo, error) {
	return fs.a.Fs.Stat(name)
}
func (fs *FakeFs) Create(name string) (File, error) {
	file, err := fs.a.Fs.Create(name)
	if err != nil {
		return nil, err
	}
	return &fakeFile{file}, nil
}
func (fs *FakeFs) Rename(oldpath, newpath string) error {
	return fs.a.Fs.Rename(oldpath, newpath)
}
func (fs *FakeFs) MkdirAll(path string, perm os.FileMode) error {
	return fs.a.Fs.MkdirAll(path, perm)
}
func (fs *FakeFs) Chtimes(name string, atime, mtime time.Time) error {
	return fs.a.Fs.Chtimes(name, atime, mtime)
}
func (fs *FakeFs) ReadFile(filename string) ([]byte, error) {
	return fs.a.ReadFile(filename)
}