Documentation ¶
Index ¶
- func ContainsString(slice []string, item string) bool
- func CopyFile(sourceFile string, destinationFile string)
- func CopyFileTo(source string, dest string) error
- func CreateDirectoryNamedPath(path string) (string, error)
- func CreateTempDir(dir string, pattern string) string
- func DeleteFile(name string) error
- func DirOrFileExists(path string) bool
- func DownloadFile(url string, dirPath string, filename string) error
- func DownloadFileTo(url string, destination string) error
- func FileExists(path string) bool
- func FileSize(path string) (int64, error)
- func GetStringBetweenDoubleQuotes(str string) (result string, found bool)
- func GetStringInBetweenTwoString(str string, startS string, endS string) (result string, found bool)
- func GetStringTrimmed(s string, sep string) []string
- func ListFiles(dir string) []os.FileInfo
- func MkDirsIfNotExist(name string) bool
- func TrimRightFile(path string, overwrite bool) error
- func ValidateCmdArgAndFlag(cmd *cobra.Command, args []string, cmdName string, arg string, flag string) error
- func ValidateCmdArgs(cmd *cobra.Command, args []string, cmdName string) error
- func WriteFile(filename string, data []byte) bool
- func WriteFileFromBox(source string, dest string) bool
- type Manual
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsString ¶
ContainsString return true if slice contains item
func CopyFileTo ¶
CopyFileTo copy a file from source to destination
func CreateDirectoryNamedPath ¶
CreateDirectoryNamedPath creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories. If path is already a directory does nothing and returns nil.
func CreateTempDir ¶
CreateTempDir creates a new temporary directory in the directory dir. The directory name is generated by taking pattern and applying a random string to the end
func DeleteFile ¶
DeleteFile removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func DirOrFileExists ¶
DirOrFileExists an error is known to report that a file or directory does not exist. It is satisfied by ErrNotExist as well as some syscall errors.
func DownloadFile ¶
DownloadFile downloads a file and saves into the given directory with the given file name
func DownloadFileTo ¶
DownloadFileTo downloads a file and saves into the given directory with the given file name
func FileExists ¶
FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.
func FileSize ¶
FileSize return the size of the give file path. Gives an error if files does not exist
func GetStringBetweenDoubleQuotes ¶
GetStringBetweenDoubleQuotes return the string between double quotes
func GetStringInBetweenTwoString ¶
func GetStringInBetweenTwoString(str string, startS string, endS string) (result string, found bool)
GetStringInBetweenTwoString return the string between two strings
func GetStringTrimmed ¶
GetStringTrimmed splits the string by the given separator and trims it by removing all spaces in between
func ListFiles ¶
ListFiles list of all file names in the given directory. Pass "." if you want to list at the current directory.
func MkDirsIfNotExist ¶
MkDirsIfNotExist creates a directory named path, along with any necessary parents, and returns true, or else returns false. The dirs have permission bits 511 (before umask) are used for all directories that this function creates. If path is already a directory, the function does nothing and returns false.
func TrimRightFile ¶
TrimRightFile open file in `path`, read line by line removing all trailing characters. Overwrite original file in `path` if `true`, it creates a new file `path`.tmp otherwise.
func ValidateCmdArgAndFlag ¶
func ValidateCmdArgAndFlag(cmd *cobra.Command, args []string, cmdName string, arg string, flag string) error
ValidateCmdArgAndFlag basic validation for the given arg on args, and if flag is empty, return error if fails
func ValidateCmdArgs ¶
ValidateCmdArgs basic validation of a command's arguments, return error if fails
func WriteFileFromBox ¶
WriteFileFromBox get the file from box's resources and write into the given destination, returns false if not able to.