util

package
v0.33.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyDirectory

func CreateEmptyDirectory(dir string) error

CreateEmptyDirectory creates an empty dir directory and returns an error if any

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 GetHomeDirectory

func GetHomeDirectory() (string, error)

GetHomeDirectory returns the path to the user's home directory

func GetSubdirectories

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

GetSubdirectories returns a slice of subdirectories in the directory dirPath

func IsEmptyFile

func IsEmptyFile(filePath string) (bool, error)

IsEmptyFile returns true if filePath is an empty file, and false otherwise

func JoinStringMaps

func JoinStringMaps(maps ...map[string]string) map[string]string

JoinStringMaps joins the given string maps

func JoinStringSlices

func JoinStringSlices(slices ...[]string) []string

JoinStringSlices joins the given slices

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 NormalizeDockerComposeLog

func NormalizeDockerComposeLog(line string) string

NormalizeDockerComposeLog removes colors, control characters, and converts carriage returns to newlines

func ParseCommand

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

ParseCommand parses the command string into a string array

func ParseDockerComposeLog

func ParseDockerComposeLog(role, line string) (string, string)

ParseDockerComposeLog parses the given docker-compose output and returns the service name and service output

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 Strip

func Strip(regex, text string) string

Strip strips off substrings that match the given regex from the given text

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