Documentation
¶
Overview ¶
Package filez provides various utilities for working with paths, files, and directories.
Index ¶
- func MustAbs(path string) string
- func MustChdir(wd string) string
- func MustCheckFileExists(fileOrDirPath string) bool
- func MustCheckPathExists(fileOrDirPath string) bool
- func MustCreateTempDir() string
- func MustCreateTempFile(contents []byte) string
- func MustCreateTempFileString(contents string) string
- func MustExport(eFS embed.FS, rootDirPath, outDirPath string)
- func MustGetwd() string
- func MustIsChild(parentPath, childPath string) bool
- func MustListRegularFilePaths(rootDirPath string) []string
- func MustPrepareDir(dirPath string, dirMode os.FileMode)
- func MustReadFile(filePath string) []byte
- func MustReadFileString(filePath string) string
- func MustRel(src, dst string) string
- func MustRelForDisplay(path string) string
- func MustRemoveAll(path string)
- func MustUserHomeDir() string
- func MustWriteFile(filePath string, dirMode, fileMode os.FileMode, contents []byte) string
- func MustWriteFileString(filePath string, dirMode, fileMode os.FileMode, contents string) string
- func WithMustCreateTempDir(f func(dirPath string))
- func WithMustCreateTempFile(contents []byte, f func(filePath string))
- func WithMustCreateTempFileString(contents string, f func(filePath string))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustCheckFileExists ¶
MustCheckFileExists checks if the given path exists and is a regular file, panics on errors other than os.ErrNotExist.
func MustCheckPathExists ¶
MustCheckPathExists checks if the given path exists, panics on errors other than os.ErrNotExist.
func MustCreateTempDir ¶
func MustCreateTempDir() string
MustCreateTempDir is like os.MkdirTemp, but panics on error.
func MustCreateTempFile ¶
MustCreateTempFile creates a temporary file with the given contents.
func MustCreateTempFileString ¶
MustCreateTempFileString creates a temporary file with the given contents.
func MustExport ¶ added in v0.11.0
MustExport exports an embedded FS to disk.
func MustIsChild ¶
MustIsChild returns true if "childPath" is lexically determined to be a child of "parentPath". Panics on error.
func MustListRegularFilePaths ¶ added in v0.11.0
MustListRegularFilePaths returns a list of regular file paths found in the given root directory, relative to it.
func MustPrepareDir ¶
MustPrepareDir deletes the given directory and its contents (if present) and recreates it.
func MustReadFile ¶
MustReadFile reads a file, panics on error.
func MustReadFileString ¶
MustReadFileString reads a file, panics on error.
func MustRel ¶
MustRel is like filepath.Rel but panics on error.
func MustRelForDisplay ¶
MustRelForDisplay converts "path" to relative if (1) it is an absolute path, and (2) it is a child of the current working directory. It returns "path" cleaned otherwise. Panics on error.
func MustRemoveAll ¶
func MustRemoveAll(path string)
MustRemoveAll is like os.RemoveAll, but panics on error.
func MustUserHomeDir ¶
func MustUserHomeDir() string
MustUserHomeDir is like os.UserHomeDir, but panics on error.
func MustWriteFile ¶
MustWriteFile creates a file with the given mode and contents, also ensuring the containing folder exists.
func MustWriteFileString ¶
MustWriteFileString creates a file with the given mode and contents, also ensuring the containing folder exists.
func WithMustCreateTempDir ¶ added in v0.13.0
func WithMustCreateTempDir(f func(dirPath string))
WithMustCreateTempDir calls WithMustCreateTempDir, then the given closure, then deletes the temp dir.
func WithMustCreateTempFile ¶ added in v0.13.0
WithMustCreateTempFile calls MustCreateTempFile, then the given closure, then deletes the temp file.
func WithMustCreateTempFileString ¶ added in v0.13.0
WithMustCreateTempFileString calls MustCreateTempFileString, then the given closure, then deletes the temp file.
Types ¶
This section is empty.