Documentation ¶
Index ¶
- Variables
- func CommandInstalled(command string) bool
- func CopyFile(source string, destination string) error
- func GuessMimeType(path string) (string, error)
- func IsDir(path string) bool
- func IsTextFile(path string) (bool, error)
- func MergeMaps(maps ...map[string]string) map[string]string
- 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 WriteFileWithSamePermissions(source string, destination string, contents []byte) error
- type NoSuchFile
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 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 MergeMaps ¶
Merge all the maps into one. Sadly, Go has no generics, so this is only defined for string 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
Types ¶
type NoSuchFile ¶
type NoSuchFile string
func (NoSuchFile) Error ¶
func (path NoSuchFile) Error() string