Create a work queue to run tasks in sequence and stop when an error is encountered
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
work.go

README.md

work

Create a work queue to run tasks in sequence and stop when an error is encountered

Install

go get github.com/whitecypher/work

Usage

work := work.Make()

// task A
work.Add(func() (err error) {
	fmt.Println("A")
	return
})

// task B
work.Add(func() (err error) {
	fmt.Println("B")
	return
})

// task C
work.Add(func() (err error) {
	fmt.Println("C")
	err = errors.New("I don't know why, but Fail!")
	return
})

// task D
work.Add(func() (err error) {
	fmt.Println("D")
	return
})

err := work.Do()
if err != nil {
	fmt.Println(err.Error())
}