filez

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 10 Imported by: 8

Documentation

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 MustCheckExists added in v1.6.0

func MustCheckExists(fileOrDirPath string) bool

MustCheckExists checks if the given path exists, panics on error (other than os.ErrNotExist).

func MustCopyEmbedFSSimple added in v1.7.0

func MustCopyEmbedFSSimple(src embed.FS, root string, outDirPath string)

MustCopyEmbedFSSimple copies regular files and directories from embed.FS to disk. Note that the copy logic is very simple and only suited for small tasks such as preparing a templated directory.

func MustCreateTempDir

func MustCreateTempDir(pattern string) string

MustCreateTempDir is like os.MkdirTemp, but panics on error.

func MustGetWD

func MustGetWD() string

MustGetWD is like os.Getwd, but 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 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 MustWriteTempFile

func MustWriteTempFile(pattern string, contents []byte) string

MustWriteTempFile creates a temporary file with the given contents.

func WithMustCreateTempDir

func WithMustCreateTempDir(pattern string, f func(dirPath string))

WithMustCreateTempDir calls f passing it the path to a new temporary directory, which is wiped after f returns.

func WithMustWriteTempFile added in v1.2.0

func WithMustWriteTempFile(pattern string, contents []byte, f func(filePath string))

WithMustWriteTempFile calls f passing it the path to a new temporary file, which is wiped after f returns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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