(Cheaper and safer than using map[string]interface{} .)

Also shows unexported state! Great for digging around.

See `go help importpath` for the details.

6. Mock out the file system

Got a package that works with the file system, but don't want your tests to actually use the disk?

var fs fileSystem = osFS{} type fileSystem interface { Open(name string) (file, error) Stat(name string) (os.FileInfo, error) } type file interface { io.Closer io.Reader io.ReaderAt io.Seeker Stat() (os.FileInfo, error) } // osFS implements fileSystem using the local disk. type osFS struct{} func (osFS) Open(name string) (file, error) { return os.Open(name) } func (osFS) Stat(name string) (os.FileInfo, error) { return os.Stat(name) }

Implement your own fake fileSystem in and put it in fs while testing.

8