runn

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: MIT Imports: 1 Imported by: 0

README

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())

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(stmts ...interface{}) error

Execute statements as stop when error

Types

type Errors

type Errors []error

Errors to handle multiple error

func (*Errors) Add

func (e *Errors) Add(err error) bool

Add the error if not nil

func (Errors) Error

func (e Errors) Error() string

type Executor

type Executor struct {
	StopWhenError bool
}

Executor do the code statement execution

func (Executor) Execute

func (e Executor) Execute(stmts ...interface{}) (err error)

Execute all statement

type Runner

type Runner interface {
	Run() error
}

Runner contain run function

Jump to

Keyboard shortcuts

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