coreutils

package module
v0.0.0-...-a4ebaf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

coreutils

A package of common utilities for command execution, input, and IO.

License

coreutils is licensed under Apache-2.0

Usage

Import
import "github.com/StroblIndustries/coreutils"
Variables
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.

Functions
func AbsPath
func AbsPath(path string) string

AbsPath get the absolute directory path, cleaning out any file names, home directory references, etc.

func CopyDirectory
func CopyDirectory(sourceDirectory, destinationDirectory string) error

CopyDirectory will copy a directory, sub-directories, and files

func CopyFile
func CopyFile(sourceFile, destinationFile string) error

CopyFile will copy a file and its relevant permissions

func ExecCommand
func ExecCommand(utility string, args []string, liveOutput bool) string

ExecCommand executes a utility with args and returning the stringified output

func ExecutableExists
func ExecutableExists(executableName string) bool

ExecutableExists checks if an executable exists

func FindClosestFile
func FindClosestFile(file string) (string, error)

FindClosestFile will return the closest related file to the one provided from a specific path

func GetFiles
func GetFiles(path string) ([]string, error)

GetFiles will get all the files from a directory.

func GetFilesContains
func GetFilesContains(path, substring string) ([]string, error)

GetFilesContains will return any files from a directory containing a particular string

func InputMessage
func InputMessage(message string) string

InputMessage fetches input after message

func IsDir
func IsDir(path string) bool

IsDir checks if the path provided is a directory or not

func OutputStatus
func OutputStatus(status bool, message string)

OutputStatus outputs a "check" or not check based on true / false status, along with the message

func Sha512Sum
func Sha512Sum(content string, rounds int) string

Sha512Sum will create a sha512sum of the string

func WriteOrUpdateFile
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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalFileMode os.FileMode

GlobalFileMode is a file mode we'll use for global IO operations.

View Source
var NonGlobalFileMode os.FileMode

NonGlobalFileMode is the file mode we'll use for non-global IO operations.

Functions

func AbsPath

func AbsPath(path string) string

AbsPath get the absolute directory path, cleaning out any file names, home directory references, etc.

func CopyDirectory

func CopyDirectory(sourceDirectory, destinationDirectory string) error

CopyDirectory will the directory specified and its contents into the destination directory

func CopyFile

func CopyFile(sourceFile, destinationFile string) error

CopyFile will copy a file and its relevant permissions

func ExecCommand

func ExecCommand(command string, args []string, redirect bool) string

ExecCommand executes a command with args and returning the stringified output

func ExecutableExists

func ExecutableExists(executableName string) bool

ExecutableExists checks if an executable exists

func GetFiles

func GetFiles(path string, recursive bool) ([]string, error)

GetFiles will get all the files from a directory.

func GetFilesContains

func GetFilesContains(path, substring string) ([]string, error)

GetFilesContains will return any files from a directory containing a particular string

func GetFilesContainsRecursive

func GetFilesContainsRecursive(path, substring string) ([]string, error)

GetFilesContainsRecursive will return any files from a directory containing a particular string, recursively

func InputMessage

func InputMessage(message string) string

InputMessage fetches input after message

func IsDir

func IsDir(path string) bool

IsDir checks if the path provided is a directory or not

func OutputStatus

func OutputStatus(status bool, message string)

OutputStatus outputs a "check" or not check based on true / false status, along with the message

func Sha512Sum

func Sha512Sum(content string, rounds int) string

Sha512Sum will create a sha512sum of the string

func WriteOrUpdateFile

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

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL