filez

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 6 Imported by: 3

Documentation

Overview

Package filez provides various utilities for working with paths, files, and directories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustAbs

func MustAbs(path string) string

MustAbs is like filepath.Abs, but panics on error.

func MustChdir

func MustChdir(wd string) string

MustChdir is like os.Chdir, but panics on error.

func MustCheckFileExists

func MustCheckFileExists(fileOrDirPath string) bool

MustCheckFileExists checks if the given path exists and is a regular file, panics on errors other than os.ErrNotExist.

func MustCheckPathExists

func MustCheckPathExists(fileOrDirPath string) bool

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

func MustCreateTempFile(contents []byte) string

MustCreateTempFile creates a temporary file with the given contents.

func MustCreateTempFileString

func MustCreateTempFileString(contents string) string

MustCreateTempFileString creates a temporary file with the given contents.

func MustGetwd

func MustGetwd() string

MustGetwd is like os.Getwd, but panics on error.

func MustIsChild

func MustIsChild(parentPath, childPath string) bool

MustIsChild returns true if "childPath" is lexically determined to be a child of "parentPath". Panics on error.

func MustPrepareDir

func MustPrepareDir(dirPath string, dirMode os.FileMode)

MustPrepareDir deletes the given directory and its contents (if present) and recreates it.

func MustReadFile

func MustReadFile(filePath string) []byte

MustReadFile reads a file, panics on error.

func MustReadFileString

func MustReadFileString(filePath string) string

MustReadFileString reads a file, panics on error.

func MustRel

func MustRel(src, dst string) string

MustRel is like filepath.Rel but panics on error.

func MustRelForDisplay

func MustRelForDisplay(path string) string

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

func MustWriteFile(filePath string, dirMode os.FileMode, fileMode os.FileMode, contents []byte) string

MustWriteFile creates a file with the given mode and contents, also ensuring the containing folder exists.

func MustWriteFileString

func MustWriteFileString(filePath string, dirMode os.FileMode, fileMode os.FileMode, contents string) string

MustWriteFileString creates a file with the given mode and contents, also ensuring the containing folder exists.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL