utils

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BashCmdExec

func BashCmdExec(cmd string, workingDir string, environ []string, logPrefix string) error

func CmdExec

func CmdExec(cmdName string, cmdArgs []string, workingDir string, environ []string, logPrefix string) error

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func ExpandPath

func ExpandPath(filePath string) (string, error)

func FileDelete added in v1.0.5

func FileDelete(filePath string) error

func FileExists

func FileExists(filePath string) bool

func FileWrite

func FileWrite(filePath string, content string, perm os.FileMode, dryRun bool) error

func LeftPad

func LeftPad(s string, padStr string, pLen int) string

func LeftPad2Len

func LeftPad2Len(s string, padStr string, overallLen int) string

func MapDeepCopy added in v1.0.6

func MapDeepCopy(m map[string]interface{}) (map[string]interface{}, error)

func MapKeys added in v1.0.5

func MapKeys(m map[string]interface{}) []string

func PopulatePathTemplate added in v1.0.11

func PopulatePathTemplate(pathTmplContent string, data interface{}) (string, error)

func PopulateTemplate

func PopulateTemplate(tmplContent string, data interface{}) (string, error)

func RightPad

func RightPad(s string, padStr string, pLen int) string

func RightPad2Len

func RightPad2Len(s string, padStr string, overallLen int) string

func SliceIncludes added in v1.0.9

func SliceIncludes(slice []string, item string) bool

func SnakeCaseToCamelCase

func SnakeCaseToCamelCase(inputUnderScoreStr string) (camelCase string)

func StdinQuery added in v1.0.4

func StdinQuery(question string) string

func StdinQueryBoolean added in v1.0.9

func StdinQueryBoolean(question string) bool

func StdinQueryInt added in v1.0.10

func StdinQueryInt(question string) (int, error)

func StdinQueryPassword added in v1.0.10

func StdinQueryPassword(question string) (string, error)

func StringToInt added in v1.0.10

func StringToInt(input string) (int, error)

func StringifyYAMLMapKeys

func StringifyYAMLMapKeys(in interface{}) interface{}

stringifyKeysMapValue recurses into in 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

Inspired by https://github.com/stripe/stripe-mock, MIT licensed

func StripIndent

func StripIndent(multilineStr string) string

func UniquePort

func UniquePort(data interface{}) (int, error)

https://play.golang.org/p/k8bws03uid

Types

This section is empty.

Jump to

Keyboard shortcuts

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