Skip to content

ibrt/golang-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-shell

Go Reference CI codecov

Fluent interface to spawn processes in Go.

Basic Example

package main

import (
    "fmt"

    "github.com/ibrt/golang-shell/shellz"
)

func main() {
    // Pipe "ls" output to terminal.
    shellz.NewCommand("ls", ".").MustRun()

    out := shellz.NewCommand("/usr/bin/env", "bash", "-c").
        AddParams("echo $MY_VAR").
        SetEnv("MY_VAR", "my-var").
        MustOutput()

    // Will output: "my-var".
    fmt.Println(out)
}

Developers

Contributions are welcome, please check in on proposed implementation before sending a PR. You can validate your changes using the ./test.sh script.