Documentation ¶
Index ¶
- type FileMap
- func (f FileMap) Clean(dir string) error
- func (f FileMap) Merge(o FileMap) FileMap
- func (f FileMap) Mine(dir, path string) bool
- func (f FileMap) Overwrite(dir string) error
- func (f FileMap) PrefixAll(prefix string) FileMap
- func (f FileMap) Session(dir string, do func()) error
- func (f FileMap) Write(dir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileMap ¶
FileMap is a map of paths to file contents.
func (FileMap) Clean ¶
Clean deletes each file defined in f, it leaves any created directories in place. If you want to nuke everything, just use os.RemoveAll(dir).
func (FileMap) Mine ¶
Mine returns true if the file at path relative to dir belongs to this FileMap. Otherwise it returns false.
func (FileMap) Overwrite ¶
Overwrite is similar to Write, except any existing files that are also defined in f are overwritten.
func (FileMap) Session ¶
Session encapsulates tearing-up the file tree defined by f, then running some code that assumes it exists, before cleaning up. If f.Write(dir) fails, do is not run, and the error is returned. Otherwise, do is run, and the error from f.Clean(dir) is returned. If do panics, then f.Clean will not be run, so you can inspect the files created in case they had something to do with it.