util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2015 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChimeError

func ChimeError(err interface{})

ChimeError outputs the bell character and then the error message, colored red and formatted.

func ChimeErrorf

func ChimeErrorf(format string, args ...interface{})

ChimeErrorf outputs the bell character and then the error message, colored red and formatted according to format and args. It works just like fmt.Printf.

func ContainsFrontMatter

func ContainsFrontMatter(r *bufio.Reader) (bool, error)

ContainsFrontMatter returns true iff the contents of r include frontmatter. It checks the first couple of bytes to see if they equal the front matter delimiter without changing the position of r.

func CopyFile

func CopyFile(srcPath string, destPath string) error

CopyFile copies the file at srcePath to destPath. It creates any directories needed for destPath.

func CreateEmptyFiles

func CreateEmptyFiles(paths []string) error

CreateEmptyFiles creates new, empty files for every path in paths. It does not write to them, and any old content that may have been there is erased.

func CreateFileWithPath

func CreateFileWithPath(path string) (*os.File, error)

CreateFileWithPath creates a file by first creating the directory the file will be placed in with os.MkdirAll (analogous to mkdir -p), and then creating the file itself. If the file already exists, it will overwrite the existing file. If there were any other problems creating the file, it will return an error.

func Recovery

func Recovery(fullStackTrace bool)

Recovery can be used to catch panics and turn them into errors. Recovery will not halt the program, though it does not guarantee that the program won't be halted for other reasons.

func RecursiveCopy

func RecursiveCopy(srcDir string, destDir string) error

RecursiveCopy copies everything from srcDir to destDir recursively. It is analogous to cp -R in unix systems.

func RemoveAllIfExists

func RemoveAllIfExists(path string) error

RemoveAllIfExists removes the directory identified by path if it exists. If it does not exist, calling this function has no effect. Contrary to the default behavior in the os package, RemoveAllIfExists will not return an error if path does not exist.

func RemoveEmptyDirs

func RemoveEmptyDirs(path string) error

RemoveEmptyDirs recursively iterates through path and removes any empty directories within it.

func RemoveIfExists

func RemoveIfExists(path string) error

RemoveIfExists removes the file identified by path if it exists. If it does not exist, calling this function has no effect. Contrary to the default behavior in the os package, RemoveIfExists will not return an error if path does not exist.

func SplitFrontMatter

func SplitFrontMatter(r *bufio.Reader) (frontMatter string, content string, err error)

SplitFrontMatter reads from r and splits its contents into two pieces: frontmatter and other content. If there is no frontmatter, then first return value will be an empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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