Documentation ¶
Index ¶
- Variables
- func CommandInstalled(command string) bool
- func CopyFile(source string, destination string) error
- func CopyFolder(srcFolder string, targetFolder string) error
- func GuessMimeType(path string) (string, error)
- func IsDir(path string) bool
- func IsTextFile(path string) (bool, error)
- func ListContains(needle string, haystack []string) bool
- func MarshalListOfObjectsToYAML(inputList []interface{}) ([]interface{}, error)
- func MergeMaps(maps ...map[string]interface{}) map[string]interface{}
- func PathExists(path string) bool
- func PromptUserForInput(prompt string) (string, error)
- func PromptUserForYesNo(prompt string) (bool, error)
- func RunCommandAndGetOutput(command string, args ...string) (string, error)
- func RunShellCommand(workingDir string, envVars []string, command string, args ...string) error
- func RunShellCommandAndGetOutput(workingDir string, envVars []string, command string, args ...string) (string, error)
- func ToString(value interface{}) string
- func ToStringList(genericList []interface{}) []string
- func ToStringMap(genericMap map[interface{}]interface{}) map[string]string
- func ToStringToGenericMap(genericMap map[interface{}]interface{}) map[string]interface{}
- func WriteFileWithSamePermissions(source string, destination string, contents []byte) error
- type NoSuchFile
- type ObjectMarshalingErr
- type UnmarshalableObjectErr
Constants ¶
This section is empty.
Variables ¶
A simple logger we can use to get consistent log formatting through out the app
Functions ¶
func CommandInstalled ¶
Return true if the OS has the given command installed
func CopyFolder ¶ added in v0.3.0
Copy all the files and folders in srcFolder to targetFolder.
func GuessMimeType ¶
Guess the mime type for the given file using a variety of heuristics. Under the hood, uses the Unix/Linux file command, if available, and Go's HTTP package otherwise.
func IsTextFile ¶
There is no way to know for sure if a file is text or binary. The best we can do is use various heuristics to guess. The best set of heuristics is in the Unix/Linux file command, so we use that if it's available. Otherwise, we turn to Go's HTTP package. For more info, see: http://stackoverflow.com/q/16760378/483528
func ListContains ¶ added in v0.0.6
Return true if the given list of strings (haystack) contains the given string (needle)
func MarshalListOfObjectsToYAML ¶ added in v0.3.6
func MarshalListOfObjectsToYAML(inputList []interface{}) ([]interface{}, error)
MarshalListOfObjectsToYAML will marshal the list of objects to yaml by calling MarshalYAML on every item in the list and return the results as a list. This is useful when building a custom YAML marshaler.
func MergeMaps ¶
Merge all the maps into one. Sadly, Go has no generics, so this is only defined for string to interface maps.
func PromptUserForInput ¶
Prompt the user for text in the CLI. Returns the text entered by the user.
func PromptUserForYesNo ¶
Prompt the user for a yes/no response and return true if they entered yes.
func RunCommandAndGetOutput ¶
Run the given command return its stdout and stderr as a string
func RunShellCommand ¶ added in v0.3.0
Run the given shell command with the given environment variables and arguments in the given working directory
func RunShellCommandAndGetOutput ¶ added in v0.3.0
func RunShellCommandAndGetOutput(workingDir string, envVars []string, command string, args ...string) (string, error)
Run the given shell command with the given environment variables and arguments in the given working directory
func ToString ¶ added in v0.3.0
func ToString(value interface{}) string
Convert a single value to its string representation
func ToStringList ¶ added in v0.3.0
func ToStringList(genericList []interface{}) []string
Convert a generic list to a list of strings
func ToStringMap ¶ added in v0.3.0
Convert a generic map to a map from string to string
func ToStringToGenericMap ¶ added in v0.3.0
func ToStringToGenericMap(genericMap map[interface{}]interface{}) map[string]interface{}
Convert a generic map to a map from string to interface
Types ¶
type NoSuchFile ¶
type NoSuchFile string
func (NoSuchFile) Error ¶
func (path NoSuchFile) Error() string
type ObjectMarshalingErr ¶ added in v0.3.6
type ObjectMarshalingErr struct {
// contains filtered or unexported fields
}
ObjectMarshalingErr is returned when there was an error marshaling the given object to yaml.
func (ObjectMarshalingErr) Error ¶ added in v0.3.6
func (err ObjectMarshalingErr) Error() string
type UnmarshalableObjectErr ¶ added in v0.3.6
type UnmarshalableObjectErr struct {
// contains filtered or unexported fields
}
UnmarshalableObjectErr is returned when the given object does not implement Marshaler interface.
func (UnmarshalableObjectErr) Error ¶ added in v0.3.6
func (err UnmarshalableObjectErr) Error() string