shell

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 5 Imported by: 0

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
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureSigTerm

func CaptureSigTerm()

func Delay

func Delay(t time.Duration, c context.Context) <-chan error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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