Documentation ¶
Overview ¶
Functions shared between borrowedtime packages.
Utilities shared between different packages.
Index ¶
- func AddExtension(filename, ext string) string
- func DeletePath(pathname string) error
- func DesktopPath() (string, error)
- func DetectApp(executable string) string
- func EscapeString(inp string) string
- func HomeDir() (string, error)
- func ListFiles(root, pattern string) (files []string, err error)
- func OpenWithDefaultEditor(path string) error
- func OpenWithEditor(editor string, paths ...string) error
- func PathExists(path string) (bool, error)
- func PrettyPrintJSON(in string, w io.Writer) error
- func ReadFileByte(filename string) ([]byte, error)
- func ReadFileString(filename string) (string, error)
- func RemoveExtension(filename string) string
- func SortedKeys(mp map[string]string) []string
- func StructToJSONString(v interface{}, indent bool) (string, error)
- func WindowsifyString(inp string) string
- func WriteFile(file string, input []byte, overwrite bool) error
- func WriteFileString(file, content string, overwrite bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddExtension ¶
AddExtension removes the old extension and adds a new one.
func DeletePath ¶
DeletePath deletes a path and all its children from disk.
func DesktopPath ¶
DesktopPath returns the path to Desktop on a Windows machine.
func DetectApp ¶
DetectApp parses the start menu, looks for an executable name (e.g. code.exe) in base paths, and returns the complete path.
func EscapeString ¶
EscapeString, escapes a single \ by converting it to "\ \".
func HomeDir ¶
HomeDir calls homedir.Dir() but changes the backslashes with forwardslashes on Windows.
func ListFiles ¶
ListFiles returns all files with a specific pattern under a path. The path is relative to root. Pattern is the typical "shell file name pattern" (e.g. *.exe or * to list all files).
func OpenWithDefaultEditor ¶
OpenWithDefaultEditor opens a file with the default editor depdening on the OS. Only Windows is supported. TODO: Add other OS default editors.
func OpenWithEditor ¶
OpenWithEditor opens paths with the editor in the config file. The editor must support passing one or more paths as the first parameter or just ignore everything after the first one.
func PathExists ¶
PathExists returns true if a path exists or cannot be accessed. Return the error if we cannot access because of a permission issue.
func PrettyPrintJSON ¶
PrettyPrintJSON gets a string and pretty prints it to io.Writer.
func ReadFileByte ¶
ReadFileByte reads the contents of a file.
func ReadFileString ¶
ReadFileString is the same as ReadFile but returns a string.
func RemoveExtension ¶
RemoveExtension removes the extension from a filename.
func SortedKeys ¶
SortedKeys returns a sorted slice of keys for a map[string]string.
func StructToJSONString ¶
StructToJSONString converts a struct into a JSON string.
func WindowsifyString ¶
WindowsifyString converts "\n" to "\r\n" in a string.
func WriteFile ¶
WriteFile writes the contents of the input to the file. File will be overwritten if overwrite is set to true.
func WriteFileString ¶
WriteFileString does the same thing that WriteFile does with a string input. I could copy WriteFile and use f.WriteString but this looks cleaner.
Types ¶
This section is empty.