v0.3.5 Latest Latest

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 11 Imported by: 2



Package helper contains generally-useful helper methods.



This section is empty.


This section is empty.


func CheckErr

func CheckErr(err error)

CheckErr panics with the given error if it is not nil.

func CleanupWithError

func CleanupWithError(tx *sql.Tx, err error) error

CleanupWithError rolls the given transaction back and if that returns errors it combines the given error and the new.

func ClearDirectory

func ClearDirectory(path string, skipFiles ...string) error

ClearDirectory clears the directory of all files and folders except the listed ones. Can only keep files directly inside the folder.

func ContainsDoNotPrintHelp

func ContainsDoNotPrintHelp(err error) bool

ContainsDoNotPrintHelp says whether the given error says to not print help.

func DoNotPrintHelp

func DoNotPrintHelp(err error) error

DoNotPrintHelp wraps the error.

func DoesPathExist

func DoesPathExist(path string) bool

DoesPathExist checks whether the given path exists inside the file system.

func DoesPathExistErr

func DoesPathExistErr(path string) (bool, error)

DoesPathExistErr returns whether the given file or directory exists

func Getwd

func Getwd() string

Getwd returns the current working directory. Panics if that fails.

func MoveFile

func MoveFile(sourcePath, destPath string) error

MoveFile copies the given file to the destination. It does not delete the source.

func PrettyJSON

func PrettyJSON(i interface{}) []byte

PrettyJSON returns the given data structure as json.

Crashes if json marshalling failed.

func PrettyJSONString

func PrettyJSONString(i interface{}) string

PrettyJSONString returns the given data structure as json.

Crashes if json marshalling failed.

func PrintAsJSON

func PrintAsJSON(i interface{})

PrintAsJSON prints the given object as indented json.

func Printwd

func Printwd()

Printwd prints the working directory.

func RequireAbsolutePathExisting

func RequireAbsolutePathExisting(path string) error

RequireAbsolutePathExisting makes sure the given path is absolute and does actually exist inside the filesystem.


This section is empty.


Path Synopsis

Jump to

Keyboard shortcuts

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