Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

typical-go/runn

Repository files navigation

Runn

GoDoc Coverage Go Report Card

Naive library to handling multiple code execution and errors

Usage

Stop immediately if some argument is error

err := runn.Execute(
    exec.Command("echo", "hello", "world"),
    SomeFunctionThatReturnError(), 
    RunnerImplementationStruct{},
)

if err != nil {
    log.Fatal(err.Error())
}

Run all argument while collect the errors

executor := runn.Executor{
    StopWhenError: false,
}
err := executor.Execute(
    exec.Command("echo", "hello", "world"),
    SomeFunctionThatReturnError(), 
    RunnerImplementationStruct{},
)

// err is Errors type
errs, ok := err.(runn.Errors)
if ok {
    for _, er := range errs{
        fmt.Println(er.Error())
    }    
}

runn.Errors is array of error

var errs runn.Errors
errs.Add(error.New("some-error"))
errs.Add(error.New("another-error"))

// aggregate error message
fmt.Println(errs.Errors())

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages