Categorygithub.com/beysed/shell
repositorypackage
0.3.1
Repository: https://github.com/beysed/shell.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Shell

Build

Quality Gate Status Coverage Maintainability Rating Reliability Rating

Shell related functions and stuff

Execute

The module provides convenient way to execute external commands and deal with its stdout/stderr as well as with stdin (see unit tests for examples)

command := MakeCommand("sed", "-e", "s/a/A/g")
execution, _ := Execute(command)

execution.Stdin <- []byte("aaa")
close(execution.Stdin)

for run := true; run; {
    select {
    case out := <-execution.Stdout:
        fmt.Print(string(out))
    case err := <-execution.Stderr:
        fmt.Println(string(err))
    case <-execution.Exit:
        run = false
    case <-time.After(time.Second * 3):
        t.Error("process killed by timeout")
        execution.Kill()
        run = false
    }
}