Documentation ¶
Index ¶
- func DetectPublicIP() (*string, error)
- func EnsureFile(path, contents string) (bool, error)
- func EnvOrDefault(key, def string) string
- func ExpandTilde(path string) (*string, error)
- func FileExists(path string) (bool, error)
- func IsStringInSlice(a string, list []string) (bool, error)
- func MustRemove(path string)
- func MustSlurp(path string) string
- func OverwriteFile(path, contents string) error
- func Slurp(path string) (*string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectPublicIP ¶
DetectPublicIP detects your public IP address and returns a pointer to a string containing the IP address or any error
func EnsureFile ¶
EnsureFile checks a file exists and writes the supplied contents if not. returns a boolean indicating whether it wrote a file or not and any error
func EnvOrDefault ¶
EnvOrDefault tries to read an environment variable with the supplied key and returns its value. EnvOrDefault returns a default value if it is empty or unset
func ExpandTilde ¶
ExpandTilde returns the fully qualified path to a file in the user's home directory. I.E. it expands a path beginning with `~/`) and checks the file exists. ExpandTilde will cache the user's home directory to amortise the cost of the syscall
func FileExists ¶
FileExists checks whether a path exists
func IsStringInSlice ¶ added in v0.6.0
IsStringInSlice checks if string a apperas in list list and returns a boolean and error if it isn't present in string
func MustRemove ¶
func MustRemove(path string)
MustRemove removes a file or empty directory. MustRemove will ignore an error if the path doesn't exist or panic for any other error
func MustSlurp ¶
MustSlurp is the panicky counterpart to Slurp. MustSlurp reads an entire file into a string in one operation and returns the contents or panics if it encouters and error
func OverwriteFile ¶
OverwriteFile writes the supplied contents overwriting the path if it already exists. It returns an error if any occurred
func Slurp ¶
Slurp reads an entire file into a string in one operation and returns a pointer to the file's content or an error if any. Similar to `ioutil.ReadFile` but it calls `filepath.Abs` first which cleans the path and resolves relative paths from the working directory.
Note that this is slightly less efficient for zero-length files than `ioutil.Readfile` as it uses the default read buffer size of `bytes.MinRead` internally
Types ¶
This section is empty.