package
0.5.1
Repository: https://github.com/awalterschulze/goderive.git
Documentation: pkg.go.dev

# README

The deriveDo function executes a list of functions concurrently and returns their results.

Given the following input:

package do

func serviceCallOne() (string, error) {
	return "a", nil
}

func serviceCallTwo() (int, error) {
	return 1, nil
}

func serviceCalls() (string, int, error) {
	return deriveDo(serviceCallOne, serviceCallTwo)
}

goderive will generate the following code:

// Code generated by goderive DO NOT EDIT.

package do

// deriveDo concurrently executes the input functions f0 and f1 and when all functions are finished the first error, if any, and results are returned.
func deriveDo(f0 func() (string, error), f1 func() (int, error)) (string, int, error) {
	errChan := make(chan error)
	var v0 string
	go func() {
		var v0err error
		v0, v0err = f0()
		errChan <- v0err
	}()
	var v1 int
	go func() {
		var v1err error
		v1, v1err = f1()
		errChan <- v1err
	}()
	var err error
	for i := 0; i < 2; i++ {
		errc := <-errChan
		if errc != nil {
			if err == nil {
				err = errc
			}
		}
	}
	return v0, v1, err
}