(ctx context.Context, cs ...chan error)
| 83 | } |
| 84 | |
| 85 | func mergeError(ctx context.Context, cs ...chan error) chan error { |
| 86 | var wg sync.WaitGroup |
| 87 | out := make(chan error) |
| 88 | |
| 89 | // Start an output goroutine for each input channel in cs. output |
| 90 | // copies values from c to out until c is closed, then calls wg.Done. |
| 91 | output := func(c <-chan error) { |
| 92 | for n := range c { |
| 93 | select { |
| 94 | case <-ctx.Done(): |
| 95 | return |
| 96 | case out <- n: |
| 97 | } |
| 98 | } |
| 99 | wg.Done() |
| 100 | } |
| 101 | wg.Add(len(cs)) |
| 102 | for _, c := range cs { |
| 103 | go output(c) |
| 104 | } |
| 105 | |
| 106 | // Start a goroutine to close out once all the output goroutines are |
| 107 | // done. This must start after the wg.Add call. |
| 108 | go func() { |
| 109 | wg.Wait() |
| 110 | close(out) |
| 111 | }() |
| 112 | return out |
| 113 | } |
| 114 | |
| 115 | func GenEthkey(credentialPath, passPhrase string) (err error) { |
| 116 | debug.FreeOSMemory() |
no test coverage detected