A package of common utilities for command execution, input, and IO.
coreutils is licensed under Apache-2.0
import "github.com/StroblIndustries/coreutils"
var GlobalFileMode os.FileMode
GlobalFileMode is a file mode we'll use for global IO operations.
var NonGlobalFileMode os.FileMode
NonGlobalFileMode is the file mode we'll use for non-global IO operations.
func AbsPath(path string) string
AbsPath get the absolute directory path, cleaning out any file names, home directory references, etc.
func CopyDirectory(sourceDirectory, destinationDirectory string) error
CopyDirectory will copy a directory, sub-directories, and files
func CopyFile(sourceFile, destinationFile string) error
CopyFile will copy a file and its relevant permissions
func ExecCommand(utility string, args []string, liveOutput bool) string
ExecCommand executes a utility with args and returning the stringified output
func ExecutableExists(executableName string) bool
ExecutableExists checks if an executable exists
func FindClosestFile(file string) (string, error)
FindClosestFile will return the closest related file to the one provided from a specific path
func GetFiles(path string) ([]string, error)
GetFiles will get all the files from a directory.
func GetFilesContains(path, substring string) ([]string, error)
GetFilesContains will return any files from a directory containing a particular string
func InputMessage(message string) string
InputMessage fetches input after message
func IsDir(path string) bool
IsDir checks if the path provided is a directory or not
func OutputStatus(status bool, message string)
OutputStatus outputs a "check" or not check based on true / false status, along with the message
func Sha512Sum(content string, rounds int) string
Sha512Sum will create a sha512sum of the string
func WriteOrUpdateFile(file string, fileContent []byte, sourceFileMode os.FileMode) error
WriteOrUpdateFile writes or updates the file contents of the passed file under the leading filepath with the specified sourceFileMode