utils

package
v0.0.0-...-4c37742 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BashStringCmd

func BashStringCmd(cmdStr string) string

BashStringCmd - Execute a bash command from a string `bash -c "(cmd)" with no log output`

func BashStringSplitOutput

func BashStringSplitOutput(cmdStr string) (string, error)

BashStringSplitOutput - Execute a bash command splitting the resulting stdout and stderr

func BufferInsert

func BufferInsert(buffer bytes.Buffer, target string, content string) bytes.Buffer

BufferInsert - Insert content into a buffer at a target string

func CheckCmd

func CheckCmd(p string) bool

CheckCmd - Checks if an executable is available and if not, returns false

func CheckCmdHard

func CheckCmdHard(p string) string

CheckCmdHard - Root executable

func CheckSudo

func CheckSudo() error

CheckSudo - Check if a user has permissions to run sudo It's up to the calling function to prime the user to input their password, and to present an error and next-steps in the event that sudo access fails

func CommandSubSplitOutput

func CommandSubSplitOutput(name string, args ...string) (string, error)

CommandSubSplitOutput - Execute a command and return the output value split into stdout and stderr. No exit on stdErr

func CommandSubSplitOutputContext

func CommandSubSplitOutputContext(directory, name string, args ...string) (string, error)

CommandSubSplitOutputContext - Execute a command and return the output value split into stdout and stderr from a directory context. No exit on stdErr

func CommandSubstitution

func CommandSubstitution(name string, args ...string) string

CommandSubstitution - Execute a command and return the output value. No exit on stdErr

func CommandSubstitutionExitCode

func CommandSubstitutionExitCode(name string, args ...string) (exitCode int)

CommandSubstitutionExitCode - Execute a command and return 0 if successful, or 1 if failed We can't return the true exit code on MacOS as this isn't a reliable method and will have if `name` is not available in the users' path (see: https://stackoverflow.com/questions/10385551/get-exit-code-go)

func ConfirmationPrompt

func ConfirmationPrompt(prompt string, weighting string) bool

ConfirmationPrompt - The 'weighting' param should be one of [ "y", "n" ].

func DebugCmd

func DebugCmd(cmd string)

DebugCmd ...

func DebugErrOutput

func DebugErrOutput(output error)

DebugErrOutput ...

func DebugOutput

func DebugOutput(output []byte)

DebugOutput ...

func DebugString

func DebugString(output string)

DebugString ...

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile - download a url to a local file.

func GainSudo

func GainSudo()

GainSudo - use `sudo true` to gain sudo privileges. Used if the user needs to specify a password to gain sudo, otherwise not necessary.

func RandomString

func RandomString() (string, error)

RandomString ...

func ReadStdin

func ReadStdin(prompt string) string

ReadStdin ...

func StdinPrompt

func StdinPrompt(prompt string) string

StdinPrompt ...

func StdoutCmd

func StdoutCmd(name string, args ...string) string

StdoutCmd - Execute a command on the users' OS

func StdoutStreamCmd

func StdoutStreamCmd(name string, args ...string)

StdoutStreamCmd - Execute a command on the users' OS and stream stdout

func StdoutStreamCmdDebug

func StdoutStreamCmdDebug(name string, args ...string)

StdoutStreamCmdDebug - Execute a command on the users' OS and stream stdout for debug only

func StdoutStreamCmdDebugContext

func StdoutStreamCmdDebugContext(directory, name string, args ...string)

StdoutStreamCmdDebugContext - Execute a command on the users' OS and stream stdout for debug only

func StreamOSCmd

func StreamOSCmd(name string, args ...string)

StreamOSCmd - Execute a command outputting OS stdout/stdin/stderr directly to the console

func StreamOSCmdContext

func StreamOSCmdContext(directory, name string, args ...string)

StreamOSCmdContext - Execute a command outputting OS stdout/stdin/stderr directly to the console from context

func StringSliceContains

func StringSliceContains(s []string, e string) bool

func Timestamp

func Timestamp() string

Timestamp - Return current timestamp in RFC3339 format

Types

This section is empty.

Jump to

Keyboard shortcuts

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