Documentation ¶
Index ¶
- func CheckRunAsRoot() bool
- func CloseChannelOnSignals(kill chan struct{}, quit chan struct{}, signals ...os.Signal)
- func CloseContextOnSignals(cancel context.CancelFunc, quit chan struct{}, signals ...os.Signal)
- func CopyFile(src, dst string) (int64, error)
- func GetFreeSpace(path string) (uint64, error)
- func IsLinuxMacOSFreeBSD() bool
- type App
- func (app *App) AddEnvironments(env []string)
- func (app *App) CheckIsInstalled() error
- func (app *App) ExitCodeOrError() *ExitCodeOrError
- func (app *App) Kill() error
- func (app *App) Run(stdin io.Reader, stdout, stderr io.Writer) ExitCodeOrError
- func (app *App) Start(stdin io.Reader, stdout, stderr io.Writer) (chan ExitCodeOrError, error)
- func (app *App) Wait() ExitCodeOrError
- type ExitCodeOrError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRunAsRoot ¶
func CheckRunAsRoot() bool
CheckRunAsRoot verify that current context is running under root privileges.
func CloseChannelOnSignals ¶
CloseChannelOnSignals close channel once signals received.
func CloseContextOnSignals ¶
func CloseContextOnSignals(cancel context.CancelFunc, quit chan struct{}, signals ...os.Signal)
CloseContextOnSignals call cancel method once signals received.
func CopyFile ¶
CopyFile copy regular file. Code taken from: https://opensource.com/article/18/6/copying-files-go
func GetFreeSpace ¶
GetFreeSpace use syscall to find free space for path specified.
func IsLinuxMacOSFreeBSD ¶
func IsLinuxMacOSFreeBSD() bool
IsLinuxMacOSFreeBSD determine that running OS belong to Linux, BSD or macOS.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App struct keep everything regarding external application started process including command line, wait channel which tracks process completion and exit code ether any exception happened in any stage of application start up or completion.
func NewApp ¶
NewApp return new application instance defined by executable name and arguments, and ready to start by following Run call.
func (*App) AddEnvironments ¶
AddEnvironments add environments in the form "key=value".
func (*App) CheckIsInstalled ¶
CheckIsInstalled use Linux/FreeBSD utility [which] to find if app is installed or not in the system.
func (*App) ExitCodeOrError ¶
func (app *App) ExitCodeOrError() *ExitCodeOrError
ExitCodeOrError return exit status once application has been finished.
func (*App) Run ¶
Run start application synchronously with link to the process stdout/stderr output, to get output. Method doesn't return control until the application finishes its execution.
func (*App) Start ¶
Start run application asynchronously and return channel to wait/track exit state and status. If application failed to run, error returned,
func (*App) Wait ¶
func (app *App) Wait() ExitCodeOrError
Wait switch from asynchronous mode to synchronous and wait until application is finished.
type ExitCodeOrError ¶
ExitCodeOrError keeps exit code from application termination either error if application failed in any stage.