util

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: MIT Imports: 14 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoesDirectoryExist

func DoesDirectoryExist(dirPath string) (bool, error)

DoesDirectoryExist returns true if the directory dirPath is an existing directory, and false otherwise

func DoesFileExist

func DoesFileExist(filePath string) (bool, error)

DoesFileExist returns true if the file filePath exists, and false otherwise

func DoesStringArrayContain

func DoesStringArrayContain(strings []string, targetString string) bool

DoesStringArrayContain returns whether the given string slice contains the given string.

func GetSubdirectories

func GetSubdirectories(dirPath string) (result []string, err error)

GetSubdirectories returns a slice of subdirectories in the directory dirPath

func MakeDirectory added in v0.29.0

func MakeDirectory(dir string) error

MakeDirectory creates a directory dir if it doesn't already exist, returns an error if any

func Merge

func Merge(map1 map[string]string, map2 map[string]string)

Merge merges two maps. It overwrites existing keys of map1 if conflicting keys exist

func MoveDirectory

func MoveDirectory(srcPath, destPath string) error

MoveDirectory moves srcPath to destPath

func ParseCommand

func ParseCommand(command string) ([]string, error)

ParseCommand parses the command string into a string array

func PrintCommandFooter added in v0.29.0

func PrintCommandFooter(writer io.Writer, elapsedTime fmt.Stringer)

PrintCommandFooter prints the time elapsed since startTime

func PrintCommandHeader added in v0.29.0

func PrintCommandHeader(writer io.Writer, text, dir string, env []string)

PrintCommandHeader prints a command header

func PrintSectionHeader added in v0.29.0

func PrintSectionHeader(writer io.Writer, text string)

PrintSectionHeader prints a section header

func PrintSectionHeaderf added in v0.29.0

func PrintSectionHeaderf(writer io.Writer, format string, a ...interface{})

PrintSectionHeaderf prints a section header with given format

func Run

func Run(dir string, commandWords ...string) (string, error)

Run runs the given command, waits for the process to finish and returns the output string and error (if any)

func RunAndPipe added in v0.29.0

func RunAndPipe(dir string, env []string, writer io.Writer, commandWords ...string) error

RunAndPipe runs the given command, and logs the process to the given writer

func RunSeries

func RunSeries(dir string, commands [][]string) error

RunSeries runs each command in commands and returns an error if any

func StringifyKeysMapValue added in v0.33.0

func StringifyKeysMapValue(v interface{}) interface{}

StringifyKeysMapValue recurses into v and changes all instances of map[interface{}]interface{} to map[string]interface{}. This is useful to work around the impedence mismatch between JSON and YAML unmarshaling that's described here:

https://github.com/go-yaml/yaml/issues/139

func ToSnake added in v0.32.0

func ToSnake(in string) string

ToSnake convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.

From: https://gist.github.com/elwinar/14e1e897fdbe4d3432e1

Types

This section is empty.

Jump to

Keyboard shortcuts

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