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 MustGetwd() string
- func MustIsChild(parentPath, childPath string) bool
- 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 os.FileMode, fileMode os.FileMode, contents []byte) string
- func MustWriteFileString(filePath string, dirMode os.FileMode, fileMode os.FileMode, contents string) 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 MustIsChild ¶
MustIsChild returns true if "childPath" is lexically determined to be a child of "parentPath". Panics on error.
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.
Types ¶
This section is empty.