util

package
v1.2.12-prerelease3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDirectoryExpected indicates that a directory was expected
	ErrDirectoryExpected = errors.New("a path to a directory was expected")
	// ErrFileExpected indicates that a file was expected
	ErrFileExpected = errors.New("a path to a file was expected")
)

Functions

func DirectoryExists

func DirectoryExists(path string) (bool, error)

DirectoryExists returns true if directory exists, false otherwise. Returns error if could not verify if directory exists or if path does not point at directory.

func FileExists

func FileExists(filepath string) (bool, error)

FileExists returns true if file exists, false otherwise. Returns error if could not verify if file exists or if path specifies directory instead of file.

func ListFiles

func ListFiles(dirPath string) ([]string, error)

ListFiles lists all files in a directory.

func ListFilesByPrefix

func ListFilesByPrefix(dirPath string, prefix string) ([]string, error)

ListFilesByPrefix lists all files in directory with prefix.

func MkdirAll

func MkdirAll(path string, dirMode os.FileMode) error

MkdirAll creates all subdirectories in given path.

func ReadFile

func ReadFile(filepath string) ([]byte, error)

ReadFile reads the contents of a file specified by filepath WARNING: callers of this method should be extremely careful not to use it in a context where filepath is supplied by the user.

func WriteFile

func WriteFile(filepath string, data []byte, fileMode os.FileMode) (retErr error)

WriteFile is used to write a file. If file already exists it is overwritten. If file does not already exist it is created.

Types

This section is empty.

Jump to

Keyboard shortcuts

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